Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: src/lazy-instance.h

Issue 303463005: Extract build configuration into a separate header and move it to the base lib (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/globals.h ('k') | src/once.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 // The LazyInstance<Type, Traits> class manages a single instance of Type, 5 // The LazyInstance<Type, Traits> class manages a single instance of Type,
6 // which will be lazily created on the first time it's accessed. This class is 6 // which will be lazily created on the first time it's accessed. This class is
7 // useful for places you would normally use a function-level static, but you 7 // useful for places you would normally use a function-level static, but you
8 // need to have guaranteed thread-safety. The Type constructor will only ever 8 // need to have guaranteed thread-safety. The Type constructor will only ever
9 // be called once, even if two threads are racing to create the object. Get() 9 // be called once, even if two threads are racing to create the object. Get()
10 // and Pointer() will always return the same, completely initialized instance. 10 // and Pointer() will always return the same, completely initialized instance.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // - "Dynamic mode". In this mode, the instance is dynamically allocated and 61 // - "Dynamic mode". In this mode, the instance is dynamically allocated and
62 // constructed (using new) by default. This mode is useful if you have to 62 // constructed (using new) by default. This mode is useful if you have to
63 // deal with some code already allocating the instance for you (e.g. 63 // deal with some code already allocating the instance for you (e.g.
64 // OS::Mutex() which returns a new private OS-dependent subclass of Mutex). 64 // OS::Mutex() which returns a new private OS-dependent subclass of Mutex).
65 // The macro LAZY_DYNAMIC_INSTANCE_INITIALIZER must be used to initialize 65 // The macro LAZY_DYNAMIC_INSTANCE_INITIALIZER must be used to initialize
66 // dynamic lazy instances. 66 // dynamic lazy instances.
67 67
68 #ifndef V8_LAZY_INSTANCE_H_ 68 #ifndef V8_LAZY_INSTANCE_H_
69 #define V8_LAZY_INSTANCE_H_ 69 #define V8_LAZY_INSTANCE_H_
70 70
71 #include "checks.h" 71 #include "base/macros.h"
72 #include "once.h" 72 #include "once.h"
73 73
74 namespace v8 { 74 namespace v8 {
75 namespace internal { 75 namespace internal {
76 76
77 #define LAZY_STATIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, { {} } } 77 #define LAZY_STATIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, { {} } }
78 #define LAZY_DYNAMIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, 0 } 78 #define LAZY_DYNAMIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, 0 }
79 79
80 // Default to static mode. 80 // Default to static mode.
81 #define LAZY_INSTANCE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER 81 #define LAZY_INSTANCE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 typename InitOnceTrait = ThreadSafeInitOnceTrait, 228 typename InitOnceTrait = ThreadSafeInitOnceTrait,
229 typename DestroyTrait = LeakyInstanceTrait<T> > 229 typename DestroyTrait = LeakyInstanceTrait<T> >
230 struct LazyDynamicInstance { 230 struct LazyDynamicInstance {
231 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, 231 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>,
232 CreateTrait, InitOnceTrait, DestroyTrait> type; 232 CreateTrait, InitOnceTrait, DestroyTrait> type;
233 }; 233 };
234 234
235 } } // namespace v8::internal 235 } } // namespace v8::internal
236 236
237 #endif // V8_LAZY_INSTANCE_H_ 237 #endif // V8_LAZY_INSTANCE_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/once.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698