Get rid of Loki
This commit is contained in:
1 parent
15a2cbe410
commit
ef0392fb63
27 files changed
+92
-52
No files matched your search
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#ifndef SINGLETON_H_INCLUDED
|
||||
#define SINGLETON_H_INCLUDED
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
namespace Loki
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct SingletonHolder
|
||||
{
|
||||
static T& Instance()
|
||||
{
|
||||
static std::once_flag onceFlag;
|
||||
|
||||
static std::unique_ptr<T> singleton;
|
||||
|
||||
std::call_once(onceFlag,
|
||||
[] {
|
||||
singleton = std::make_unique<T>();
|
||||
});
|
||||
|
||||
return *singleton.get();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user