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

Method cleanupTLSForThread

Engine/TLSHolder.cpp:120–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 9

tiledRenderingFunctorMethod · 0.80
getMarkerImageMethod · 0.80
trackStepFunctorMethod · 0.80
threadLoopOnceMethod · 0.80
runMethod · 0.80
Node.cppFile · 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