MCPcopy Create free account
hub / github.com/MrKepzie/Natron / cleanupTLSForThread

Method cleanupTLSForThread

Engine/TLSHolder.cpp:119–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119void
120AppTLS::cleanupTLSForThread()
121{
122 QThread* curThread = QThread::currentThread();
123 AbortableThread* isAbortableThread = dynamic_cast<AbortableThread*>(curThread);
124
125 if (isAbortableThread) {
126 isAbortableThread->clearAbortInfo();
127 }
128
129 //Cleanup any cached data on the TLSHolder
130 {
131 QWriteLocker l(&_spawnsMutex);
132
133 //This thread was spawned, but TLS not used, do not bother to clean-up
134 ThreadSpawnMap::iterator foundSpawned = _spawns.find(curThread);
135 if ( foundSpawned != _spawns.end() ) {
136 _spawns.erase(foundSpawned);
137
138 return;
139 }
140 }
141 std::list<boost::shared_ptr<const TLSHolderBase> > objectsToClean;
142 {
143 QReadLocker k (&_objectMutex);
144 const TLSObjects& objectsCRef = _object->objects;
145 for (TLSObjects::iterator it = objectsCRef.begin();
146 it != objectsCRef.end();
147 ++it) {
148 boost::shared_ptr<const TLSHolderBase> p = (*it).lock();
149 if (p) {
150 if ( p->canCleanupPerThreadData(curThread) ) {
151 objectsToClean.push_back(p);
152 }
153 }
154 }
155 }
156 if ( !objectsToClean.empty() ) {
157#if 1
158 // version from 1a0712b
159 // should be OK, since the bug in 1a0712b was in canCleanupPerThreadData
160 QWriteLocker k (&_objectMutex);
161 for (std::list<boost::shared_ptr<const TLSHolderBase> >::iterator it = objectsToClean.begin();
162 it != objectsToClean.end();
163 ++it) {
164 if ( (*it)->cleanupPerThreadData(curThread) ) {
165 TLSObjects::iterator found = _object->objects.find(*it);
166 if ( found != _object->objects.end() ) {
167 _object->objects.erase(found);
168 }
169 }
170 }
171#else
172 // original version
173 TLSObjects newObjects;
174 QWriteLocker k (&_objectMutex);
175 for (TLSObjects::iterator it = _object->objects.begin();
176 it != _object->objects.end(); ++it) {

Callers 9

tiledRenderingFunctorMethod · 0.80
getMarkerImageMethod · 0.80
trackStepFunctorMethod · 0.80
threadLoopOnceMethod · 0.80
runMethod · 0.80
getRotoContextMethod · 0.80
threadFunctionWrapperFunction · 0.80
OfxThreadClass · 0.80

Calls 11

clearAbortInfoMethod · 0.80
emptyMethod · 0.80
cleanupPerThreadDataMethod · 0.80
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
lockMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected