mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
use std::call_once instead of bool flag
This commit is contained in:
parent
2d80ce8203
commit
59948a41a6
1
Global.h
1
Global.h
@ -138,6 +138,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
//The only available version is 3, as of Boost 1.50
|
//The only available version is 3, as of Boost 1.50
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
@ -705,12 +705,8 @@ namespace VCMIDirs
|
|||||||
static VCMIDirsIOS singleton;
|
static VCMIDirsIOS singleton;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool initialized = false;
|
static std::once_flag flag;
|
||||||
if (!initialized)
|
std::call_once(flag, [] { singleton.init(); });
|
||||||
{
|
|
||||||
singleton.init();
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user