1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/thread.cpp
3 // Purpose: wxThread Implementation
4 // Author: Original from Wolfram Gloger/Guilhem Lavaux/David Webster
5 // Modified by: Stefan Neis
8 // Copyright: (c) Stefan Neis (2003)
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation "thread.h"
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
29 #include "wx/module.h"
33 #include "wx/thread.h"
35 #define INCL_DOSSEMAPHORES
36 #define INCL_DOSPROCESS
43 // the possible states of the thread ("=>" shows all possible transitions from
47 STATE_NEW
, // didn't start execution yet (=> RUNNING)
48 STATE_RUNNING
, // thread is running (=> PAUSED, CANCELED)
49 STATE_PAUSED
, // thread is temporarily suspended (=> RUNNING)
50 STATE_CANCELED
, // thread should terminate a.s.a.p. (=> EXITED)
51 STATE_EXITED
// thread is terminating
54 // ----------------------------------------------------------------------------
55 // this module's globals
56 // ----------------------------------------------------------------------------
58 // id of the main thread - the one which can call GUI functions without first
59 // calling wxMutexGuiEnter()
60 static ULONG s_ulIdMainThread
= 1;
61 wxMutex
* p_wxMainMutex
;
63 // OS2 substitute for Tls pointer the current parent thread object
64 wxThread
* m_pThread
; // pointer to the wxWindows thread object
66 // if it's FALSE, some secondary thread is holding the GUI lock
67 static bool gs_bGuiOwnedByMainThread
= TRUE
;
69 // critical section which controls access to all GUI functions: any secondary
70 // thread (i.e. except the main one) must enter this crit section before doing
72 static wxCriticalSection
*gs_pCritsectGui
= NULL
;
74 // critical section which protects s_nWaitingForGui variable
75 static wxCriticalSection
*gs_pCritsectWaitingForGui
= NULL
;
77 // number of threads waiting for GUI in wxMutexGuiEnter()
78 static size_t gs_nWaitingForGui
= 0;
80 // are we waiting for a thread termination?
81 static bool gs_bWaitingForThread
= FALSE
;
83 // ============================================================================
84 // OS/2 implementation of thread and related classes
85 // ============================================================================
87 // ----------------------------------------------------------------------------
88 // wxMutex implementation
89 // ----------------------------------------------------------------------------
93 wxMutexInternal(wxMutexType mutexType
);
96 bool IsOk() const { return m_vMutex
!= NULL
; }
98 wxMutexError
Lock() { return LockTimeout(SEM_INDEFINITE_WAIT
); }
99 wxMutexError
TryLock() { return LockTimeout(SEM_IMMEDIATE_RETURN
); }
100 wxMutexError
Unlock();
103 wxMutexError
LockTimeout(ULONG ulMilliseconds
);
107 // all mutexes are "pseudo-"recursive under OS2 so we don't use mutexType
108 // (Calls to DosRequestMutexSem and DosReleaseMutexSem can be nested, but
109 // the request count for a semaphore cannot exceed 65535. If an attempt is
110 // made to exceed this number, ERROR_TOO_MANY_SEM_REQUESTS is returned.)
111 wxMutexInternal::wxMutexInternal(
112 wxMutexType
WXUNUSED(eMutexType
)
117 ulrc
= ::DosCreateMutexSem(NULL
, &m_vMutex
, 0L, FALSE
);
120 wxLogSysError(_("Can not create mutex."));
125 wxMutexInternal::~wxMutexInternal()
129 if (::DosCloseMutexSem(m_vMutex
))
130 wxLogLastError(_T("DosCloseMutexSem(mutex)"));
134 wxMutexError
wxMutexInternal::LockTimeout(ULONG ulMilliseconds
)
138 ulrc
= ::DosRequestMutexSem(m_vMutex
, ulMilliseconds
);
143 case ERROR_TOO_MANY_SEM_REQUESTS
:
150 case ERROR_INVALID_HANDLE
:
151 case ERROR_INTERRUPT
:
152 case ERROR_SEM_OWNER_DIED
:
153 wxLogSysError(_("Couldn't acquire a mutex lock"));
154 return wxMUTEX_MISC_ERROR
;
157 wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock"));
158 return wxMUTEX_MISC_ERROR
;
160 return wxMUTEX_NO_ERROR
;
163 wxMutexError
wxMutexInternal::Unlock()
167 ulrc
= ::DosReleaseMutexSem(m_vMutex
);
170 wxLogSysError(_("Couldn't release a mutex"));
171 return wxMUTEX_MISC_ERROR
;
173 return wxMUTEX_NO_ERROR
;
176 // --------------------------------------------------------------------------
178 // --------------------------------------------------------------------------
180 // a trivial wrapper around OS2 event semaphore
181 class wxSemaphoreInternal
184 wxSemaphoreInternal(int initialcount
, int maxcount
);
185 ~wxSemaphoreInternal();
187 bool IsOk() const { return m_vEvent
!= NULL
; }
189 wxSemaError
Wait() { return WaitTimeout(SEM_INDEFINITE_WAIT
); }
190 wxSemaError
TryWait() { return WaitTimeout(SEM_IMMEDIATE_RETURN
); }
191 wxSemaError
WaitTimeout(unsigned long milliseconds
);
202 wxSemaphoreInternal::wxSemaphoreInternal(int initialcount
, int maxcount
)
207 // make it practically infinite
211 m_count
= initialcount
;
212 m_maxcount
= maxcount
;
213 ulrc
= ::DosCreateMutexSem(NULL
, &m_vMutex
, 0L, FALSE
);
216 wxLogLastError(_T("DosCreateMutexSem()"));
221 ulrc
= ::DosCreateEventSem(NULL
, &m_vEvent
, 0L, FALSE
);
224 wxLogLastError(_T("DosCreateEventSem()"));
225 ::DosCloseMutexSem(m_vMutex
);
230 ::DosPostEventSem(m_vEvent
);
233 wxSemaphoreInternal::~wxSemaphoreInternal()
237 if ( ::DosCloseEventSem(m_vEvent
) )
239 wxLogLastError(_T("DosCloseEventSem(semaphore)"));
241 if ( ::DosCloseMutexSem(m_vMutex
) )
243 wxLogLastError(_T("DosCloseMutexSem(semaphore)"));
250 wxSemaError
wxSemaphoreInternal::WaitTimeout(unsigned long ulMilliseconds
)
254 ulrc
= ::DosWaitEventSem(m_vEvent
, ulMilliseconds
);
261 if (ulMilliseconds
== SEM_IMMEDIATE_RETURN
)
264 return wxSEMA_TIMEOUT
;
267 wxLogLastError(_T("DosWaitEventSem(semaphore)"));
268 return wxSEMA_MISC_ERROR
;
270 ulrc
= :: DosRequestMutexSem(m_vMutex
, ulMilliseconds
);
278 case ERROR_TOO_MANY_SEM_REQUESTS
:
279 if (ulMilliseconds
== SEM_IMMEDIATE_RETURN
)
282 return wxSEMA_TIMEOUT
;
285 wxFAIL_MSG(wxT("DosRequestMutexSem(mutex)"));
286 return wxSEMA_MISC_ERROR
;
297 ::DosResetEventSem(m_vEvent
, &ulPostCount
);
299 ::DosReleaseMutexSem(m_vMutex
);
301 return wxSEMA_NO_ERROR
;
302 } while (ulMilliseconds
== SEM_INDEFINITE_WAIT
);
304 if (ulMilliseconds
== SEM_IMMEDIATE_RETURN
)
306 return wxSEMA_TIMEOUT
;
309 wxSemaError
wxSemaphoreInternal::Post()
312 ulrc
= ::DosRequestMutexSem(m_vMutex
, SEM_INDEFINITE_WAIT
);
313 if (ulrc
!= NO_ERROR
)
314 return wxSEMA_MISC_ERROR
;
316 if (m_count
< m_maxcount
)
319 ulrc
= ::DosPostEventSem(m_vEvent
);
322 ::DosReleaseMutexSem(m_vMutex
);
324 return wxSEMA_OVERFLOW
;
325 if ( ulrc
!= NO_ERROR
&& ulrc
!= ERROR_ALREADY_POSTED
)
327 wxLogLastError(_T("DosPostEventSem(semaphore)"));
329 return wxSEMA_MISC_ERROR
;
332 return wxSEMA_NO_ERROR
;
335 // ----------------------------------------------------------------------------
336 // wxThread implementation
337 // ----------------------------------------------------------------------------
339 // wxThreadInternal class
340 // ----------------------
342 class wxThreadInternal
345 inline wxThreadInternal()
348 m_eState
= STATE_NEW
;
349 m_nPriority
= WXTHREAD_DEFAULT_PRIORITY
;
357 // create a new (suspended) thread (for the given thread object)
358 bool Create( wxThread
* pThread
359 ,unsigned int uStackSize
362 // suspend/resume/terminate
365 inline void Cancel() { m_eState
= STATE_CANCELED
; }
368 inline void SetState(wxThreadState eState
) { m_eState
= eState
; }
369 inline wxThreadState
GetState() const { return m_eState
; }
372 void SetPriority(unsigned int nPriority
);
373 inline unsigned int GetPriority() const { return m_nPriority
; }
375 // thread handle and id
376 inline TID
GetHandle() const { return m_hThread
; }
377 TID
GetId() const { return m_hThread
; }
380 static DWORD
OS2ThreadStart(ULONG ulParam
);
383 // Threads in OS/2 have only an ID, so m_hThread is both it's handle and ID
384 // PM also has no real Tls mechanism to index pointers by so we'll just
385 // keep track of the wxWindows parent object here.
386 TID m_hThread
; // handle and ID of the thread
387 wxThreadState m_eState
; // state, see wxThreadState enum
388 unsigned int m_nPriority
; // thread priority in "wx" units
391 ULONG
wxThreadInternal::OS2ThreadStart(
398 // first of all, check whether we hadn't been cancelled already and don't
399 // start the user code at all then
400 wxThread
*pThread
= (wxThread
*)ulParam
;
401 if ( pThread
->m_internal
->GetState() == STATE_EXITED
)
404 bWasCancelled
= TRUE
;
406 else // do run thread
408 dwRet
= (DWORD
)pThread
->Entry();
410 // enter m_critsect before changing the thread state
411 pThread
->m_critsect
.Enter();
413 bWasCancelled
= pThread
->m_internal
->GetState() == STATE_CANCELED
;
415 pThread
->m_internal
->SetState(STATE_EXITED
);
416 pThread
->m_critsect
.Leave();
420 // if the thread was cancelled (from Delete()), then it the handle is still
422 if (pThread
->IsDetached() && !bWasCancelled
)
427 //else: the joinable threads handle will be closed when Wait() is done
431 void wxThreadInternal::SetPriority(
432 unsigned int nPriority
435 // translate wxWindows priority to the PM one
436 ULONG ulOS2_PriorityClass
;
437 ULONG ulOS2_SubPriority
;
440 m_nPriority
= nPriority
;
441 if (m_nPriority
<= 25)
442 ulOS2_PriorityClass
= PRTYC_IDLETIME
;
443 else if (m_nPriority
<= 50)
444 ulOS2_PriorityClass
= PRTYC_REGULAR
;
445 else if (m_nPriority
<= 75)
446 ulOS2_PriorityClass
= PRTYC_TIMECRITICAL
;
447 else if (m_nPriority
<= 100)
448 ulOS2_PriorityClass
= PRTYC_FOREGROUNDSERVER
;
451 wxFAIL_MSG(wxT("invalid value of thread priority parameter"));
452 ulOS2_PriorityClass
= PRTYC_REGULAR
;
454 ulOS2_SubPriority
= (ULONG
) (((m_nPriority
- 1) % 25 + 1) * 31.0 / 25);
455 ulrc
= ::DosSetPriority( PRTYS_THREAD
462 wxLogSysError(_("Can't set thread priority"));
466 bool wxThreadInternal::Create(
468 , unsigned int uStackSize
473 ulrc
= ::DosCreateThread( &m_hThread
474 ,(PFNTHREAD
)wxThreadInternal::OS2ThreadStart
476 ,CREATE_SUSPENDED
| STACK_SPARSE
481 wxLogSysError(_("Can't create thread"));
485 if (m_nPriority
!= WXTHREAD_DEFAULT_PRIORITY
)
487 SetPriority(m_nPriority
);
493 bool wxThreadInternal::Suspend()
495 ULONG ulrc
= ::DosSuspendThread(m_hThread
);
499 wxLogSysError(_("Can not suspend thread %lu"), m_hThread
);
502 m_eState
= STATE_PAUSED
;
506 bool wxThreadInternal::Resume()
508 ULONG ulrc
= ::DosResumeThread(m_hThread
);
512 wxLogSysError(_("Can not suspend thread %lu"), m_hThread
);
516 // don't change the state from STATE_EXITED because it's special and means
517 // we are going to terminate without running any user code - if we did it,
518 // the codei n Delete() wouldn't work
519 if ( m_eState
!= STATE_EXITED
)
521 m_eState
= STATE_RUNNING
;
530 wxThread
*wxThread::This()
532 wxThread
* pThread
= m_pThread
;
536 bool wxThread::IsMain()
541 ::DosGetInfoBlocks(&ptib
, &ppib
);
543 if (ptib
->tib_ptib2
->tib2_ultid
== s_ulIdMainThread
)
552 void wxThread::Yield()
557 void wxThread::Sleep(
558 unsigned long ulMilliseconds
561 ::DosSleep(ulMilliseconds
);
564 int wxThread::GetCPUCount()
568 ulrc
= ::DosQuerySysInfo(26, 26, (void *)&CPUCount
, sizeof(ULONG
));
569 // QSV_NUMPROCESSORS(26) is typically not defined in header files
577 unsigned long wxThread::GetCurrentId()
582 ::DosGetInfoBlocks(&ptib
, &ppib
);
583 return (unsigned long) ptib
->tib_ptib2
->tib2_ultid
;
586 bool wxThread::SetConcurrency(size_t level
)
588 wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") );
590 // ok only for the default one
594 // Don't know how to realize this on OS/2.
601 wxThread::wxThread(wxThreadKind kind
)
603 m_internal
= new wxThreadInternal();
605 m_isDetached
= kind
== wxTHREAD_DETACHED
;
608 wxThread::~wxThread()
613 // create/start thread
614 // -------------------
616 wxThreadError
wxThread::Create(
617 unsigned int uStackSize
620 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
622 if ( !m_internal
->Create(this, uStackSize
) )
623 return wxTHREAD_NO_RESOURCE
;
625 return wxTHREAD_NO_ERROR
;
628 wxThreadError
wxThread::Run()
630 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
632 if ( m_internal
->GetState() != STATE_NEW
)
634 // actually, it may be almost any state at all, not only STATE_RUNNING
635 return wxTHREAD_RUNNING
;
640 // suspend/resume thread
641 // ---------------------
643 wxThreadError
wxThread::Pause()
645 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
647 return m_internal
->Suspend() ? wxTHREAD_NO_ERROR
: wxTHREAD_MISC_ERROR
;
650 wxThreadError
wxThread::Resume()
652 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
654 return m_internal
->Resume() ? wxTHREAD_NO_ERROR
: wxTHREAD_MISC_ERROR
;
660 wxThread::ExitCode
wxThread::Wait()
662 // although under Windows we can wait for any thread, it's an error to
663 // wait for a detached one in wxWin API
664 wxCHECK_MSG( !IsDetached(), (ExitCode
)-1,
665 _T("can't wait for detached thread") );
666 ExitCode rc
= (ExitCode
)-1;
671 wxThreadError
wxThread::Delete(ExitCode
*pRc
)
675 // Delete() is always safe to call, so consider all possible states
677 // we might need to resume the thread, but we might also not need to cancel
678 // it if it doesn't run yet
679 bool shouldResume
= FALSE
,
683 // check if the thread already started to run
685 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
687 if ( m_internal
->GetState() == STATE_NEW
)
689 // WinThreadStart() will see it and terminate immediately, no need
690 // to cancel the thread - but we still need to resume it to let it
692 m_internal
->SetState(STATE_EXITED
);
694 Resume(); // it knows about STATE_EXITED special case
696 shouldCancel
= FALSE
;
699 // shouldResume is correctly set to FALSE here
703 shouldResume
= IsPaused();
707 // resume the thread if it is paused
711 TID hThread
= m_internal
->GetHandle();
713 if ( isRunning
|| IsRunning())
717 // set flag for wxIsWaitingForThread()
718 gs_bWaitingForThread
= TRUE
;
721 // ask the thread to terminate
724 wxCriticalSectionLocker
lock(m_critsect
);
726 m_internal
->Cancel();
730 // we can't just wait for the thread to terminate because it might be
731 // calling some GUI functions and so it will never terminate before we
732 // process the Windows messages that result from these functions
733 DWORD result
= 0; // suppress warnings from broken compilers
738 // give the thread we're waiting for chance to do the GUI call
740 if ( (gs_nWaitingForGui
> 0) && wxGuiOwnedByMainThread() )
746 result
= ::DosWaitThread(&hThread
, DCWW_WAIT
);
747 // FIXME: We ought to have a message processing loop here!!
751 case ERROR_THREAD_NOT_TERMINATED
:
752 case ERROR_INVALID_THREADID
:
754 wxLogSysError(_("Can not wait for thread termination"));
756 return wxTHREAD_KILLED
;
759 // thread we're waiting for terminated
763 wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
765 } while ( result
!= NO_ERROR
);
767 // simply wait for the thread to terminate
769 // OTOH, even console apps create windows (in wxExecute, for WinSock
770 // &c), so may be use MsgWaitForMultipleObject() too here?
771 if ( ::DosWaitThread(&hThread
, DCWW_WAIT
) != NO_ERROR
)
773 wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
775 #endif // wxUSE_GUI/!wxUSE_GUI
779 gs_bWaitingForThread
= FALSE
;
784 // although the thread might be already in the EXITED state it might not
785 // have terminated yet and so we are not sure that it has actually
786 // terminated if the "if" above hadn't been taken
789 if ( !::GetExitCodeThread(hThread
, (LPDWORD
)&rc
) )
791 wxLogLastError(wxT("GetExitCodeThread"));
795 } while ( (DWORD
)rc
== STILL_ACTIVE
);
800 // if the thread exits normally, this is done in WinThreadStart, but in
801 // this case it would have been too early because
802 // MsgWaitForMultipleObject() would fail if the thread handle was
803 // closed while we were waiting on it, so we must do it here
810 return rc
== (ExitCode
)-1 ? wxTHREAD_MISC_ERROR
: wxTHREAD_NO_ERROR
;
813 wxThreadError
wxThread::Kill()
816 return wxTHREAD_NOT_RUNNING
;
818 ::DosKillThread(m_internal
->GetHandle());
823 return wxTHREAD_NO_ERROR
;
831 ::DosExit(EXIT_THREAD
, ULONG(pStatus
));
832 wxFAIL_MSG(wxT("Couldn't return from DosExit()!"));
835 void wxThread::SetPriority(
839 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
841 m_internal
->SetPriority(nPrio
);
844 unsigned int wxThread::GetPriority() const
846 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
848 return m_internal
->GetPriority();
851 unsigned long wxThread::GetId() const
853 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
); // const_cast
855 return (unsigned long)m_internal
->GetId();
858 bool wxThread::IsRunning() const
860 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
862 return(m_internal
->GetState() == STATE_RUNNING
);
865 bool wxThread::IsAlive() const
867 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
869 return (m_internal
->GetState() == STATE_RUNNING
) ||
870 (m_internal
->GetState() == STATE_PAUSED
);
873 bool wxThread::IsPaused() const
875 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
877 return (m_internal
->GetState() == STATE_PAUSED
);
880 bool wxThread::TestDestroy()
882 wxCriticalSectionLocker
lock((wxCriticalSection
&)m_critsect
);
884 return m_internal
->GetState() == STATE_CANCELED
;
887 // ----------------------------------------------------------------------------
888 // Automatic initialization for thread module
889 // ----------------------------------------------------------------------------
891 class wxThreadModule
: public wxModule
894 virtual bool OnInit();
895 virtual void OnExit();
898 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
901 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)
903 bool wxThreadModule::OnInit()
905 gs_pCritsectWaitingForGui
= new wxCriticalSection();
907 gs_pCritsectGui
= new wxCriticalSection();
908 gs_pCritsectGui
->Enter();
913 ::DosGetInfoBlocks(&ptib
, &ppib
);
915 s_ulIdMainThread
= ptib
->tib_ptib2
->tib2_ultid
;
919 void wxThreadModule::OnExit()
923 gs_pCritsectGui
->Leave();
924 #if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
925 delete gs_pCritsectGui
;
927 gs_pCritsectGui
= NULL
;
930 #if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
931 wxDELETE(gs_pCritsectWaitingForGui
);
935 // ----------------------------------------------------------------------------
937 // ----------------------------------------------------------------------------
939 // wake up the main thread if it's in ::GetMessage()
940 void WXDLLEXPORT
wxWakeUpMainThread()
942 if ( !::WinPostQueueMsg(wxTheApp
->m_hMq
, WM_NULL
, 0, 0) )
944 // should never happen
945 wxLogLastError(wxT("WinPostMessage(WM_NULL)"));
949 void WXDLLEXPORT
wxMutexGuiEnter()
951 // this would dead lock everything...
952 wxASSERT_MSG( !wxThread::IsMain(),
953 wxT("main thread doesn't want to block in wxMutexGuiEnter()!") );
955 // the order in which we enter the critical sections here is crucial!!
957 // set the flag telling to the main thread that we want to do some GUI
959 wxCriticalSectionLocker
enter(*gs_pCritsectWaitingForGui
);
964 wxWakeUpMainThread();
966 // now we may block here because the main thread will soon let us in
967 // (during the next iteration of OnIdle())
968 gs_pCritsectGui
->Enter();
971 void WXDLLEXPORT
wxMutexGuiLeave()
973 wxCriticalSectionLocker
enter(*gs_pCritsectWaitingForGui
);
975 if ( wxThread::IsMain() )
977 gs_bGuiOwnedByMainThread
= FALSE
;
981 // decrement the number of waiters now
982 wxASSERT_MSG(gs_nWaitingForGui
> 0,
983 wxT("calling wxMutexGuiLeave() without entering it first?") );
987 wxWakeUpMainThread();
990 gs_pCritsectGui
->Leave();
993 void WXDLLEXPORT
wxMutexGuiLeaveOrEnter()
995 wxASSERT_MSG( wxThread::IsMain(),
996 wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") );
998 wxCriticalSectionLocker
enter(*gs_pCritsectWaitingForGui
);
1000 if (gs_nWaitingForGui
== 0)
1002 // no threads are waiting for GUI - so we may acquire the lock without
1003 // any danger (but only if we don't already have it)
1004 if (!wxGuiOwnedByMainThread())
1006 gs_pCritsectGui
->Enter();
1008 gs_bGuiOwnedByMainThread
= TRUE
;
1010 //else: already have it, nothing to do
1014 // some threads are waiting, release the GUI lock if we have it
1015 if (wxGuiOwnedByMainThread())
1019 //else: some other worker thread is doing GUI
1023 bool WXDLLEXPORT
wxGuiOwnedByMainThread()
1025 return gs_bGuiOwnedByMainThread
;
1028 bool WXDLLEXPORT
wxIsWaitingForThread()
1030 return gs_bWaitingForThread
;
1033 // ----------------------------------------------------------------------------
1034 // include common implementation code
1035 // ----------------------------------------------------------------------------
1037 #include "wx/thrimpl.cpp"