91 #ifndef V8_LAZY_INSTANCE_H_
92 #define V8_LAZY_INSTANCE_H_
100 #define LAZY_STATIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, { {} } }
101 #define LAZY_DYNAMIC_INSTANCE_INITIALIZER { V8_ONCE_INIT, 0 }
104 #define LAZY_INSTANCE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
107 template <
typename T>
116 template <
typename T>
126 return reinterpret_cast<T*
>(storage);
129 template <
typename ConstructTrait>
136 template <
typename T>
144 template <
typename CreateTrait>
146 *storage = CreateTrait::Create();
151 template <
typename T>
155 new(allocated_ptr)
T();
160 template <
typename T>
169 template <
typename Function,
typename Storage>
178 template <
typename Function,
typename Storage>
189 template <
typename T,
typename AllocationTrait,
typename CreateTrait,
190 typename InitOnceTrait,
typename DestroyTrait >
197 AllocationTrait::template InitStorageUsingTrait<CreateTrait>(storage);
205 reinterpret_cast<void(*)(
void*)
>(&InitInstance),
206 reinterpret_cast<void*>(&
storage_));
212 return AllocationTrait::MutableInstance(&
storage_);
217 return *AllocationTrait::MutableInstance(&
storage_);
228 template <
typename T,
234 CreateTrait, InitOnceTrait, DestroyTrait>
type;
238 template <
typename T,
249 template <
typename T,
255 CreateTrait, InitOnceTrait, DestroyTrait>
type;
260 #endif // V8_LAZY_INSTANCE_H_
static T * MutableInstance(StorageType *storage)
struct V8_ALIGNAS(T, 16) StorageType
static void Construct(T *allocated_ptr)
AllocationTrait::StorageType StorageType
void CallOnce(OnceType *once, NoArgFunction init_func)
static void InitStorageUsingTrait(StorageType *storage)
LazyInstanceImpl< T, StaticallyAllocatedInstanceTrait< T >, CreateTrait, InitOnceTrait, DestroyTrait > type
static void InitStorageUsingTrait(StorageType *storage)
static void Init(OnceType *once, Function function, Storage storage)
#define T(name, string, precedence)
static T * MutableInstance(StorageType *storage)
static void Init(OnceType *once, Function function, Storage storage)
LazyStaticInstance< T, CreateTrait, InitOnceTrait, DestroyTrait >::type type
LazyInstanceImpl< T, DynamicallyAllocatedInstanceTrait< T >, CreateTrait, InitOnceTrait, DestroyTrait > type
STATIC_ASSERT(V8_ALIGNOF(StorageType) >=V8_ALIGNOF(T))