Lines Matching refs:instance
5 // The LazyInstance<Type, Traits> class manages a single instance of Type,
10 // and Pointer() will always return the same, completely initialized instance.
11 // When the instance is constructed it is registered with AtExitManager. The
21 // will manage a unique instance. It also preallocates the space for Type, as
22 // to avoid allocating the Type instance on the heap. This may help with the
23 // performance of creating the instance, and reducing heap fragmentation. This
61 static Type* New(void* instance) {
62 DCHECK_EQ(reinterpret_cast<uintptr_t>(instance) & (ALIGNOF(Type) - 1), 0u);
63 // Use placement new to initialize our instance in our preallocated space.
65 return new (instance) Type();
68 static void CallDestructor(Type* instance) {
70 instance->~Type();
88 static Type* New(void* instance) {
89 return LazyInstanceTraitsBase<Type>::New(instance);
92 static void Delete(Type* instance) {
93 LazyInstanceTraitsBase<Type>::CallDestructor(instance);
112 static Type* New(void* instance) {
114 return LazyInstanceTraitsBase<Type>::New(instance);
116 static void Delete(Type* instance) {
127 // Check if instance needs to be created. If so return true otherwise
128 // if another thread has beat us, wait for instance to be created and
132 // After creating an instance, call this to register the dtor to be called
170 // If any bit in the created mask is true, the instance has already been
175 // We will hopefully have fast access when the instance is already created.
185 // Create the instance in the space provided by |private_buf_|.
191 return instance();
201 return p == instance();
210 // Preallocated space for the Type instance.
214 Type* instance() {
220 // Calling OnExit while the instance is in use by other threads is a mistake.
224 Traits::Delete(me->instance());