|
|
@ -29,7 +29,9 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
static inline void destroy() |
|
|
|
static inline void destroy() |
|
|
|
{ |
|
|
|
{ |
|
|
|
VERIFY(s_instance, "singleton does not exist"); |
|
|
|
if (!s_instance) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete s_instance; |
|
|
|
delete s_instance; |
|
|
|
s_instance = nullptr; |
|
|
|
s_instance = nullptr; |
|
|
@ -44,6 +46,13 @@ public: |
|
|
|
protected: |
|
|
|
protected: |
|
|
|
Singleton() {} |
|
|
|
Singleton() {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Hack: in certain situations the instance needs to be set early
|
|
|
|
|
|
|
|
static void set(T* instance) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VERIFY(!s_instance, "singleton already exists"); |
|
|
|
|
|
|
|
s_instance = instance; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Constructor token
|
|
|
|
// Constructor token
|
|
|
|
struct s {}; |
|
|
|
struct s {}; |
|
|
|
|
|
|
|
|
|
|
|