mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 20:42:53 +08:00
Update matrix.cpp
Fix race condition in getDefaultAllocator and setDefaultAllocator interaction / not threadsafe currently
This commit is contained in:
parent
d72ddc8255
commit
cf4e9e5ce2
@ -222,16 +222,20 @@ public:
|
|||||||
};
|
};
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
MatAllocator* g_matAllocator = NULL;
|
MatAllocator* volatile g_matAllocator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MatAllocator* Mat::getDefaultAllocator()
|
MatAllocator* Mat::getDefaultAllocator()
|
||||||
{
|
{
|
||||||
|
if (g_matAllocator == NULL)
|
||||||
|
{
|
||||||
|
cv::AutoLock lock(cv::getInitializationMutex());
|
||||||
if (g_matAllocator == NULL)
|
if (g_matAllocator == NULL)
|
||||||
{
|
{
|
||||||
g_matAllocator = getStdAllocator();
|
g_matAllocator = getStdAllocator();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return g_matAllocator;
|
return g_matAllocator;
|
||||||
}
|
}
|
||||||
void Mat::setDefaultAllocator(MatAllocator* allocator)
|
void Mat::setDefaultAllocator(MatAllocator* allocator)
|
||||||
|
Loading…
Reference in New Issue
Block a user