Skip to content

Commit

Permalink
Merge pull request #17492 from cyyever:fix_data_race
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Jun 10, 2020
2 parents 25f3a11 + 171cba4 commit 55ca0fc
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions modules/core/src/precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 55ca0fc

Please sign in to comment.