// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
wxThreadError wxThreadInternal::Run()
{
wxCHECK_MSG( GetState() == STATE_NEW, wxTHREAD_RUNNING,
wxThreadError wxThreadInternal::Run()
{
wxCHECK_MSG( GetState() == STATE_NEW, wxTHREAD_RUNNING,
// the mutex was locked on Create(), so we will be able to lock it again
// only when the thread really starts executing and enters the wait -
// the mutex was locked on Create(), so we will be able to lock it again
// only when the thread really starts executing and enters the wait -
// if the thread we're waiting for is waiting for the GUI mutex, we will
// deadlock so make sure we release it temporarily
// if the thread we're waiting for is waiting for the GUI mutex, we will
// deadlock so make sure we release it temporarily
// 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();
// 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();
// the state is set from the thread which pauses us first, this function
// is called later so the state should have been already set
wxCHECK_RET( m_state == STATE_PAUSED,
// the state is set from the thread which pauses us first, this function
// is called later so the state should have been already set
wxCHECK_RET( m_state == STATE_PAUSED,
// don't pause the thread which is being terminated - this would lead to
// deadlock if the thread is paused after Delete() had called Resume() but
// don't pause the thread which is being terminated - this would lead to
// deadlock if the thread is paused after Delete() had called Resume() but
void wxThreadInternal::Resume()
{
wxCHECK_RET( m_state == STATE_PAUSED,
void wxThreadInternal::Resume()
{
wxCHECK_RET( m_state == STATE_PAUSED,
// we will be able to lock this mutex only when Pause() starts waiting
wxMutexLocker lock(m_mutexSuspend);
// we will be able to lock this mutex only when Pause() starts waiting
wxMutexLocker lock(m_mutexSuspend);
{
wxCHECK_RET( ((int)WXTHREAD_MIN_PRIORITY <= (int)prio) &&
((int)prio <= (int)WXTHREAD_MAX_PRIORITY),
{
wxCHECK_RET( ((int)WXTHREAD_MIN_PRIORITY <= (int)prio) &&
((int)prio <= (int)WXTHREAD_MAX_PRIORITY),
// next wake up the threads waiting for us (OTOH, this function won't return
// until someone waited for us!)
// next wake up the threads waiting for us (OTOH, this function won't return
// until someone waited for us!)
//--------------------------------------------------------------------
// wxThreadModule
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// wxThreadModule
//--------------------------------------------------------------------