+
+ // entering Wait() releases the mutex thus allowing SignalExit() to acquire
+ // it and to signal us its termination
+ m_cond.Wait(m_mutex);
+
+ // mutex is still in the locked state - relocked on exit from Wait(), so
+ // unlock it - we don't need it any more, the thread has already terminated
+ m_mutex.Unlock();
+
+ // reacquire GUI mutex
+ if ( wxThread::IsMain() )
+ wxMutexGuiEnter();
+}
+
+void wxThreadInternal::SignalExit()
+{
+ // as mutex is currently locked, this will block until some other thread
+ // (normally the same which created this one) unlocks it by entering Wait()
+ m_mutex.Lock();
+
+ // wake up all the threads waiting for our termination
+ m_cond.Broadcast();
+
+ // after this call mutex will be finally unlocked
+ m_mutex.Unlock();
+}
+
+void wxThreadInternal::Pause()
+{
+ wxCHECK_RET( m_state == STATE_PAUSED,
+ "thread must first be paused with wxThread::Pause()." );
+
+ // wait until the condition is signaled from Resume()
+ m_condSuspend.Wait(m_mutexSuspend);
+}
+
+void wxThreadInternal::Resume()
+{
+ wxCHECK_RET( m_state == STATE_PAUSED,
+ "can't resume thread which is not suspended." );
+
+ // we will be able to lock this mutex only when Pause() starts waiting
+ wxMutexLocker lock(m_mutexSuspend);
+ m_condSuspend.Signal();
+
+ SetState(STATE_RUNNING);