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

Side by Side Diff: base/lazy_instance.h

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 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
« no previous file with comments | « base/json/string_escape_unittest.cc ('k') | base/lazy_instance.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 (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 // 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 21 matching lines...) Expand all
32 // ptr->DoDoDo(); // MyClass::DoDoDo 32 // ptr->DoDoDo(); // MyClass::DoDoDo
33 // } 33 // }
34 34
35 #ifndef BASE_LAZY_INSTANCE_H_ 35 #ifndef BASE_LAZY_INSTANCE_H_
36 #define BASE_LAZY_INSTANCE_H_ 36 #define BASE_LAZY_INSTANCE_H_
37 37
38 #include <new> // For placement new. 38 #include <new> // For placement new.
39 39
40 #include "base/atomicops.h" 40 #include "base/atomicops.h"
41 #include "base/base_export.h" 41 #include "base/base_export.h"
42 #include "base/basictypes.h"
43 #include "base/debug/leak_annotations.h" 42 #include "base/debug/leak_annotations.h"
44 #include "base/logging.h" 43 #include "base/logging.h"
45 #include "base/memory/aligned_memory.h" 44 #include "base/memory/aligned_memory.h"
46 #include "base/threading/thread_restrictions.h" 45 #include "base/threading/thread_restrictions.h"
47 46
48 // LazyInstance uses its own struct initializer-list style static 47 // LazyInstance uses its own struct initializer-list style static
49 // initialization, as base's LINKER_INITIALIZED requires a constructor and on 48 // initialization, as base's LINKER_INITIALIZED requires a constructor and on
50 // some compilers (notably gcc 4.4) this still ends up needing runtime 49 // some compilers (notably gcc 4.4) this still ends up needing runtime
51 // initialization. 50 // initialization.
52 #define LAZY_INSTANCE_INITIALIZER {0} 51 #define LAZY_INSTANCE_INITIALIZER {0}
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 LazyInstance<Type, Traits>* me = 198 LazyInstance<Type, Traits>* me =
200 reinterpret_cast<LazyInstance<Type, Traits>*>(lazy_instance); 199 reinterpret_cast<LazyInstance<Type, Traits>*>(lazy_instance);
201 Traits::Delete(me->instance()); 200 Traits::Delete(me->instance());
202 subtle::NoBarrier_Store(&me->private_instance_, 0); 201 subtle::NoBarrier_Store(&me->private_instance_, 0);
203 } 202 }
204 }; 203 };
205 204
206 } // namespace base 205 } // namespace base
207 206
208 #endif // BASE_LAZY_INSTANCE_H_ 207 #endif // BASE_LAZY_INSTANCE_H_
OLDNEW
« no previous file with comments | « base/json/string_escape_unittest.cc ('k') | base/lazy_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698