mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 06:10:02 +08:00
use C++11 static variables as memory barrier
This commit is contained in:
parent
434014b05e
commit
171cba4947
@ -364,15 +364,8 @@ bool __termination; // skip some cleanups, because process is terminating
|
||||
|
||||
cv::Mutex& getInitializationMutex();
|
||||
|
||||
// TODO Memory barriers?
|
||||
#define CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, RET_VALUE) \
|
||||
static TYPE* volatile instance = NULL; \
|
||||
if (instance == NULL) \
|
||||
{ \
|
||||
cv::AutoLock lock(cv::getInitializationMutex()); \
|
||||
if (instance == NULL) \
|
||||
instance = INITIALIZER; \
|
||||
} \
|
||||
static TYPE* const instance = INITIALIZER; \
|
||||
return RET_VALUE;
|
||||
|
||||
#define CV_SINGLETON_LAZY_INIT(TYPE, INITIALIZER) CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, instance)
|
||||
|
Loading…
Reference in New Issue
Block a user