// This method is here to 'wrap' the internal thread's virtual method call with some standard setup/tear-down code of our own void Thread::InternalThreadEntryAux() { const uint32 threadStackBase = 0; // only here so we can get its address below _threadStackBase = &threadStackBase; // remember this stack location so GetCurrentStackUsage() can reference it later on muscle_thread_key curThreadKey = GetCurrentThreadKey(); if (_curThreadsMutex.Lock() == B_NO_ERROR) { (void) _curThreads.Put(curThreadKey, this); _curThreadsMutex.Unlock(); } if ((_threadPriority != PRIORITY_UNSPECIFIED)&&(SetThreadPriorityAux(_threadPriority) != B_NO_ERROR)) { LogTime(MUSCLE_LOG_ERROR, "Thread %p: Unable to set thread priority to %i\n", this, _threadPriority); } if (_threadData[MESSAGE_THREAD_OWNER]._messages.HasItems()) SignalOwner(); InternalThreadEntry(); _threadData[MESSAGE_THREAD_INTERNAL]._messageSocket.Reset(); // this will wake up the owner thread with EOF on socket if (_curThreadsMutex.Lock() == B_NO_ERROR) { (void) _curThreads.Remove(curThreadKey); _curThreadsMutex.Unlock(); } _threadStackBase = NULL; }
Thread * Thread :: GetCurrentThread() { muscle_thread_key key = GetCurrentThreadKey(); Thread * ret = NULL; if (_curThreadsMutex.Lock() == B_NO_ERROR) { (void) _curThreads.Get(key, ret); _curThreadsMutex.Unlock(); } return ret; }
// This method is here to 'wrap' the internal thread's virtual method call with some standard setup/tear-down code of our own void Thread::InternalThreadEntryAux() { const uint32 threadStackBase = 0; // only here so we can get its address below _threadStackBase = &threadStackBase; // remember this stack location so GetCurrentStackUsage() can reference it later on muscle_thread_key curThreadKey = GetCurrentThreadKey(); if (_curThreadsMutex.Lock() == B_NO_ERROR) { (void) _curThreads.Put(curThreadKey, this); _curThreadsMutex.Unlock(); } if (_threadData[MESSAGE_THREAD_OWNER]._messages.HasItems()) SignalOwner(); InternalThreadEntry(); _threadData[MESSAGE_THREAD_INTERNAL]._messageSocket.Reset(); // this will wake up the owner thread with EOF on socket if (_curThreadsMutex.Lock() == B_NO_ERROR) { (void) _curThreads.Remove(curThreadKey); _curThreadsMutex.Unlock(); } _threadStackBase = NULL; }