OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 private: | 184 private: |
185 static void InitInstance(StorageType* storage) { | 185 static void InitInstance(StorageType* storage) { |
186 AllocationTrait::template InitStorageUsingTrait<CreateTrait>(storage); | 186 AllocationTrait::template InitStorageUsingTrait<CreateTrait>(storage); |
187 } | 187 } |
188 | 188 |
189 void Init() const { | 189 void Init() const { |
190 InitOnceTrait::Init( | 190 InitOnceTrait::Init( |
191 &once_, | 191 &once_, |
192 // Casts to void* are needed here to avoid breaking strict aliasing | 192 // Casts to void* are needed here to avoid breaking strict aliasing |
193 // rules. | 193 // rules. |
194 reinterpret_cast<void (*)(void*)>(&InitInstance), | 194 reinterpret_cast<void(*)(void*)>(&InitInstance), // NOLINT |
195 reinterpret_cast<void*>(&storage_)); | 195 reinterpret_cast<void*>(&storage_)); |
196 } | 196 } |
197 | 197 |
198 public: | 198 public: |
199 T* Pointer() { | 199 T* Pointer() { |
200 Init(); | 200 Init(); |
201 return AllocationTrait::MutableInstance(&storage_); | 201 return AllocationTrait::MutableInstance(&storage_); |
202 } | 202 } |
203 | 203 |
204 const T& Get() const { | 204 const T& Get() const { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 typename InitOnceTrait = SingleThreadInitOnceTrait, | 239 typename InitOnceTrait = SingleThreadInitOnceTrait, |
240 typename DestroyTrait = LeakyInstanceTrait<T> > | 240 typename DestroyTrait = LeakyInstanceTrait<T> > |
241 struct LazyDynamicInstance { | 241 struct LazyDynamicInstance { |
242 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, | 242 typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, |
243 CreateTrait, InitOnceTrait, DestroyTrait> type; | 243 CreateTrait, InitOnceTrait, DestroyTrait> type; |
244 }; | 244 }; |
245 | 245 |
246 } } // namespace v8::internal | 246 } } // namespace v8::internal |
247 | 247 |
248 #endif // V8_LAZY_INSTANCE_H_ | 248 #endif // V8_LAZY_INSTANCE_H_ |
OLD | NEW |