From 171cba49478c4553c94192895167e38333a3b674 Mon Sep 17 00:00:00 2001 From: cyy Date: Tue, 9 Jun 2020 15:49:31 +0800 Subject: [PATCH] use C++11 static variables as memory barrier --- modules/core/src/precomp.hpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 874067cbeb..836488f439 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -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)