----------------------------------------------------------------------------- Function: ThreadRunHandler Summary: Calls Thread::run() with the thread's specified run argument. Neccesary because Thread::run() is provided as a non-threaded way to execute the thread's run function. So we have to keep track of the thread's lock here.
| 44 | // way to execute the thread's run function. So we have to keep |
| 45 | // track of the thread's lock here. |
| 46 | static void *ThreadRunHandler(void * arg) |
| 47 | { |
| 48 | PlatformThreadData *mData = reinterpret_cast<PlatformThreadData*>(arg); |
| 49 | Thread *thread = mData->mThread; |
| 50 | |
| 51 | mData->mThreadID = ThreadManager::getCurrentThreadId(); |
| 52 | ThreadManager::addThread(thread); |
| 53 | thread->run(mData->mRunArg); |
| 54 | |
| 55 | mData->mGateway.release(); |
| 56 | // we could delete the Thread here, if it wants to be auto-deleted... |
| 57 | if(thread->autoDelete) |
| 58 | { |
| 59 | ThreadManager::removeThread(thread); |
| 60 | delete thread; |
| 61 | } |
| 62 | // return value for pthread lib's benefit |
| 63 | return NULL; |
| 64 | // the end of this function is where the created pthread will die. |
| 65 | } |
| 66 | |
| 67 | //----------------------------------------------------------------------------- |
| 68 | Thread::Thread(ThreadRunFunction func, void* arg, bool start_thread, bool autodelete) |