| 174 | } |
| 175 | |
| 176 | void asCThreadManager::Unprepare() |
| 177 | { |
| 178 | asASSERT(threadManager); |
| 179 | |
| 180 | if( threadManager == 0 ) |
| 181 | return; |
| 182 | |
| 183 | // It's necessary to protect this section so no |
| 184 | // other thread attempts to call AddRef or Release |
| 185 | // while clean up is in progress. |
| 186 | ENTERCRITICALSECTION(threadManager->criticalSection); |
| 187 | if( --threadManager->refCount == 0 ) |
| 188 | { |
| 189 | // Make sure the local data is destroyed, at least for the current thread |
| 190 | CleanupLocalData(); |
| 191 | |
| 192 | // As the critical section will be destroyed together |
| 193 | // with the thread manager we must first clear the global |
| 194 | // variable in case a new thread manager needs to be created; |
| 195 | asCThreadManager *mgr = threadManager; |
| 196 | threadManager = 0; |
| 197 | |
| 198 | // Leave the critical section before it is destroyed |
| 199 | LEAVECRITICALSECTION(mgr->criticalSection); |
| 200 | |
| 201 | asDELETE(mgr,asCThreadManager); |
| 202 | } |
| 203 | else |
| 204 | LEAVECRITICALSECTION(threadManager->criticalSection); |
| 205 | } |
| 206 | |
| 207 | asCThreadManager::~asCThreadManager() |
| 208 | { |
no outgoing calls
no test coverage detected