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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Alternatively, you could explicitly control which swap function is | 57 // Alternatively, you could explicitly control which swap function is |
58 // used by providing your own traits class or using one of the | 58 // used by providing your own traits class or using one of the |
59 // pre-defined ones below. See comments on traits below for details. | 59 // pre-defined ones below. See comments on traits below for details. |
60 // | 60 // |
61 // NOTE: Some complexity is necessary in order to use Immutable<T> | 61 // NOTE: Some complexity is necessary in order to use Immutable<T> |
62 // with forward-declared types. See comments on traits below for | 62 // with forward-declared types. See comments on traits below for |
63 // details. | 63 // details. |
64 | 64 |
65 #ifndef SYNC_UTIL_IMMUTABLE_H_ | 65 #ifndef SYNC_UTIL_IMMUTABLE_H_ |
66 #define SYNC_UTIL_IMMUTABLE_H_ | 66 #define SYNC_UTIL_IMMUTABLE_H_ |
67 #pragma once | |
68 | 67 |
69 // For std::swap(). | 68 // For std::swap(). |
70 #include <algorithm> | 69 #include <algorithm> |
71 | 70 |
72 #include "base/basictypes.h" | 71 #include "base/basictypes.h" |
73 #include "base/memory/ref_counted.h" | 72 #include "base/memory/ref_counted.h" |
74 | 73 |
75 namespace syncer { | 74 namespace syncer { |
76 | 75 |
77 namespace internal { | 76 namespace internal { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 252 |
254 // Helper function to avoid having to write out template arguments. | 253 // Helper function to avoid having to write out template arguments. |
255 template <typename T> | 254 template <typename T> |
256 Immutable<T> MakeImmutable(T* t) { | 255 Immutable<T> MakeImmutable(T* t) { |
257 return Immutable<T>(t); | 256 return Immutable<T>(t); |
258 } | 257 } |
259 | 258 |
260 } // namespace syncer | 259 } // namespace syncer |
261 | 260 |
262 #endif // SYNC_UTIL_IMMUTABLE_H_ | 261 #endif // SYNC_UTIL_IMMUTABLE_H_ |
OLD | NEW |