1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2021-04-15 20:50:26 +00:00
12 changed files with 135 additions and 92 deletions
+12 -1
View File
@@ -1520,6 +1520,9 @@ struct ThreadData
size_t idx; // Thread index in TLS storage. This is not OS thread ID!
};
static bool g_isTlsStorageInitialized = false;
// Main TLS storage class
class TlsStorage
{
@@ -1529,6 +1532,7 @@ public:
{
tlsSlots.reserve(32);
threads.reserve(32);
g_isTlsStorageInitialized = true;
}
~TlsStorage()
{
@@ -1747,6 +1751,13 @@ static void WINAPI opencv_fls_destructor(void* pData)
} // namespace details
using namespace details;
void releaseTlsStorageThread()
{
if (!g_isTlsStorageInitialized)
return; // nothing to release, so prefer to avoid creation of new global structures
getTlsStorage().releaseThread();
}
TLSDataContainer::TLSDataContainer()
{
key_ = (int)getTlsStorage().reserveSlot(this); // Reserve key from TLS storage
@@ -1830,7 +1841,7 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpReserved)
{
// Not allowed to free resources if lpReserved is non-null
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583.aspx
cv::getTlsStorage().releaseThread();
releaseTlsStorageThread();
}
}
return TRUE;