From 2054123890a3b2167e2f845047cacc0f1063afc3 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 4 Feb 2015 13:03:27 +0300 Subject: [PATCH] coreTlsData -> getCoreTlsData() --- modules/core/src/ocl.cpp | 8 ++++---- modules/core/src/precomp.hpp | 2 +- modules/core/src/rand.cpp | 2 +- modules/core/src/system.cpp | 24 ++++++++++++++++-------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index efe3b936d5..f7117d8a71 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1471,7 +1471,7 @@ bool haveOpenCL() bool useOpenCL() { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); if( data->useOpenCL < 0 ) { try @@ -1490,7 +1490,7 @@ void setUseOpenCL(bool flag) { if( haveOpenCL() ) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); data->useOpenCL = (flag && Device::getDefault().ptr() != NULL) ? 1 : 0; } } @@ -2161,7 +2161,7 @@ size_t Device::profilingTimerResolution() const const Device& Device::getDefault() { const Context& ctx = Context::getDefault(); - int idx = coreTlsData.get()->device; + int idx = getCoreTlsData().get()->device; const Device& device = ctx.device(idx); return device; } @@ -3040,7 +3040,7 @@ void* Queue::ptr() const Queue& Queue::getDefault() { - Queue& q = coreTlsData.get()->oclQueue; + Queue& q = getCoreTlsData().get()->oclQueue; if( !q.p && haveOpenCL() ) q.create(Context::getDefault()); return q; diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 0f85cc5568..b35be6ecc2 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -255,7 +255,7 @@ struct CoreTLSData #endif }; -extern TLSData coreTlsData; +TLSData& getCoreTlsData(); #if defined(BUILD_SHARED_LIBS) #if defined WIN32 || defined _WIN32 || defined WINCE diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 1b71900baa..bd1d80ca2b 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -731,7 +731,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, cv::RNG& cv::theRNG() { - return coreTlsData.get()->rng; + return getCoreTlsData().get()->rng; } void cv::randu(InputOutputArray dst, InputArray low, InputArray high) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 2590f215a9..43d5bd0a0b 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1146,12 +1146,20 @@ TLSStorage::~TLSStorage() tlsData_.clear(); } -TLSData coreTlsData; + + +TLSData& getCoreTlsData() +{ + static TLSData *value = new TLSData(); + return *value; +} + + #ifdef CV_COLLECT_IMPL_DATA void setImpl(int flags) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); data->implFlags = flags; data->implCode.clear(); data->implFun.clear(); @@ -1159,7 +1167,7 @@ void setImpl(int flags) void addImpl(int flag, const char* func) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); data->implFlags |= flag; if(func) // use lazy collection if name was not specified { @@ -1174,7 +1182,7 @@ void addImpl(int flag, const char* func) int getImpl(std::vector &impl, std::vector &funName) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); impl = data->implCode; funName = data->implFun; return data->implFlags; // return actual flags for lazy collection @@ -1182,13 +1190,13 @@ int getImpl(std::vector &impl, std::vector &funName) bool useCollection() { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); return data->useCollection; } void setUseCollection(bool flag) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); data->useCollection = flag; } #endif @@ -1221,7 +1229,7 @@ String getIppErrorLocation() bool useIPP() { #ifdef HAVE_IPP - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); if(data->useIPP < 0) { const char* pIppEnv = getenv("OPENCV_IPP"); @@ -1238,7 +1246,7 @@ bool useIPP() void setUseIPP(bool flag) { - CoreTLSData* data = coreTlsData.get(); + CoreTLSData* data = getCoreTlsData().get(); #ifdef HAVE_IPP data->useIPP = flag; #else -- GitLab