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
46 static void New(void* instance) {
47 // Use placement new to initialize our instance in our preallocated space.
49 new (instance) Type();
51 static void Delete(void* instance) {
53 reinterpret_cast<Type*>(instance)->~Type();
71 // Make sure that instance is created, creating or waiting for it to be
73 // |instance| and registers dtor for destruction at program exit.
74 void EnsureInstance(void* instance, void (*ctor)(void*), void (*dtor)(void*));
98 Type* instance = reinterpret_cast<Type*>(&buf_);
100 // We will hopefully have fast access when the instance is already created.
102 EnsureInstance(instance, Traits::New, Traits::Delete);
107 // "ctor(instance)" in EnsureInstance(...) happens before
108 // "return instance" in Pointer().
112 return instance;
116 int8 buf_[sizeof(Type)]; // Preallocate the space for the Type instance.