| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Immutable<T> provides an easy, cheap, and thread-safe way to pass | 5 // Immutable<T> provides an easy, cheap, and thread-safe way to pass |
| 6 // large immutable data around. | 6 // large immutable data around. |
| 7 // | 7 // |
| 8 // For example, consider the following code: | 8 // For example, consider the following code: |
| 9 // | 9 // |
| 10 // typedef std::vector<LargeObject> LargeObjectList; | 10 // typedef std::vector<LargeObject> LargeObjectList; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // ---------- | 151 // ---------- |
| 152 // #include ".../immutable.h" | 152 // #include ".../immutable.h" |
| 153 // | 153 // |
| 154 // // Forward declaration. | 154 // // Forward declaration. |
| 155 // class SomeOtherType; | 155 // class SomeOtherType; |
| 156 // | 156 // |
| 157 // class MyClass { | 157 // class MyClass { |
| 158 // ... | 158 // ... |
| 159 // private: | 159 // private: |
| 160 // struct ImmutableSomeOtherTypeTraits { | 160 // struct ImmutableSomeOtherTypeTraits { |
| 161 // // scoped_ptr<SomeOtherType> won't work here, either. | 161 // // std::unique_ptr<SomeOtherType> won't work here, either. |
| 162 // typedef SomeOtherType* Wrapper; | 162 // typedef SomeOtherType* Wrapper; |
| 163 // | 163 // |
| 164 // static void InitializeWrapper(Wrapper* wrapper); | 164 // static void InitializeWrapper(Wrapper* wrapper); |
| 165 // | 165 // |
| 166 // static void DestroyWrapper(Wrapper* wrapper); | 166 // static void DestroyWrapper(Wrapper* wrapper); |
| 167 // ... | 167 // ... |
| 168 // }; | 168 // }; |
| 169 // | 169 // |
| 170 // typedef Immutable<SomeOtherType, ImmutableSomeOtherTypeTraits> | 170 // typedef Immutable<SomeOtherType, ImmutableSomeOtherTypeTraits> |
| 171 // ImmutableSomeOtherType; | 171 // ImmutableSomeOtherType; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 // Helper function to avoid having to write out template arguments. | 253 // Helper function to avoid having to write out template arguments. |
| 254 template <typename T> | 254 template <typename T> |
| 255 Immutable<T> MakeImmutable(T* t) { | 255 Immutable<T> MakeImmutable(T* t) { |
| 256 return Immutable<T>(t); | 256 return Immutable<T>(t); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace syncer | 259 } // namespace syncer |
| 260 | 260 |
| 261 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_IMMUTABLE_H_ | 261 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_IMMUTABLE_H_ |
| OLD | NEW |