1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

core(TLS): add cleanup() method

This commit is contained in:
Alexander Alekhin
2017-02-15 20:20:38 +03:00
parent 526220a171
commit ec7f74f7b4
2 changed files with 20 additions and 5 deletions
@@ -627,6 +627,9 @@ public:
virtual void deleteDataInstance(void* pData) const = 0;
int key_;
public:
void cleanup(); //! Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid.
};
// Main TLS data class
@@ -638,13 +641,15 @@ public:
inline ~TLSData() { release(); } // Release key and delete associated data
inline T* get() const { return (T*)getData(); } // Get data associated with key
// Get data from all threads
// Get data from all threads
inline void gather(std::vector<T*> &data) const
{
std::vector<void*> &dataVoid = reinterpret_cast<std::vector<void*>&>(data);
gatherData(dataVoid);
}
inline void cleanup() { TLSDataContainer::cleanup(); }
private:
virtual void* createDataInstance() const {return new T;} // Wrapper to allocate data by template
virtual void deleteDataInstance(void* pData) const {delete (T*)pData;} // Wrapper to release data by template