Merge pull request #21612 from seanm:tsan-call-once

pull/21630/head
Alexander Alekhin 3 years ago
commit 5cf1dca36e
  1. 20
      modules/core/src/matrix.cpp

@ -176,27 +176,23 @@ public:
}
};
namespace
static
MatAllocator*& getDefaultAllocatorMatRef()
{
MatAllocator* volatile g_matAllocator = NULL;
static MatAllocator* g_matAllocator = Mat::getStdAllocator();
return g_matAllocator;
}
MatAllocator* Mat::getDefaultAllocator()
{
if (g_matAllocator == NULL)
{
cv::AutoLock lock(cv::getInitializationMutex());
if (g_matAllocator == NULL)
{
g_matAllocator = getStdAllocator();
}
}
return g_matAllocator;
return getDefaultAllocatorMatRef();
}
void Mat::setDefaultAllocator(MatAllocator* allocator)
{
g_matAllocator = allocator;
getDefaultAllocatorMatRef() = allocator;
}
MatAllocator* Mat::getStdAllocator()
{
CV_SINGLETON_LAZY_INIT(MatAllocator, new StdMatAllocator())

Loading…
Cancel
Save