@@ -1086,7 +1086,7 @@ class TlsStorage
1086
1086
}
1087
1087
1088
1088
// Release TLS storage index and pass associated data to caller
1089
- void releaseSlot (size_t slotIdx, std::vector<void *> &dataVec)
1089
+ void releaseSlot (size_t slotIdx, std::vector<void *> &dataVec, bool keepSlot = false )
1090
1090
{
1091
1091
AutoLock guard (mtxGlobalAccess);
1092
1092
CV_Assert (tlsSlots.size () > slotIdx);
@@ -1099,12 +1099,13 @@ class TlsStorage
1099
1099
if (thread_slots.size () > slotIdx && thread_slots[slotIdx])
1100
1100
{
1101
1101
dataVec.push_back (thread_slots[slotIdx]);
1102
- threads[i]-> slots [ slotIdx] = 0 ;
1102
+ thread_slots[ slotIdx] = NULL ;
1103
1103
}
1104
1104
}
1105
1105
}
1106
1106
1107
- tlsSlots[slotIdx] = 0 ;
1107
+ if (!keepSlot)
1108
+ tlsSlots[slotIdx] = 0 ;
1108
1109
}
1109
1110
1110
1111
// Get data by TLS storage index
@@ -1196,9 +1197,18 @@ void TLSDataContainer::release()
1196
1197
std::vector<void *> data;
1197
1198
data.reserve (32 );
1198
1199
getTlsStorage ().releaseSlot (key_, data); // Release key and get stored data for proper destruction
1200
+ key_ = -1 ;
1201
+ for (size_t i = 0 ; i < data.size (); i++) // Delete all associated data
1202
+ deleteDataInstance (data[i]);
1203
+ }
1204
+
1205
+ void TLSDataContainer::cleanup ()
1206
+ {
1207
+ std::vector<void *> data;
1208
+ data.reserve (32 );
1209
+ getTlsStorage ().releaseSlot (key_, data, true ); // Extract stored data with removal from TLS tables
1199
1210
for (size_t i = 0 ; i < data.size (); i++) // Delete all associated data
1200
1211
deleteDataInstance (data[i]);
1201
- key_ = -1 ;
1202
1212
}
1203
1213
1204
1214
void * TLSDataContainer::getData () const
0 commit comments