X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9838df2cefc5b368bb11f98c784ecc78f45ecaf7..a6aa9b1ee8aaecdf0ca4618c2e6cccfb011f4599:/include/wx/thread.h diff --git a/include/wx/thread.h b/include/wx/thread.h index 1acb78279f..c47aca3449 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -13,10 +13,6 @@ #ifndef __THREADH__ #define __THREADH__ -#ifdef __GNUG__ - #pragma interface "thread.h" -#endif - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -25,6 +21,10 @@ #include "wx/setup.h" #if wxUSE_THREADS +/* otherwise we get undefined references for non-thread case (KB)*/ +#ifdef __GNUG__ + #pragma interface "thread.h" +#endif // Windows headers define it #ifdef Yield @@ -134,7 +134,7 @@ private: // in order to avoid any overhead under !MSW make all wxCriticalSection class // functions inline - but this can't be done under MSW -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXPM__) class WXDLLEXPORT wxCriticalSectionInternal; #define WXCRITICAL_INLINE #else // !MSW @@ -151,16 +151,16 @@ public: WXCRITICAL_INLINE ~wxCriticalSection(); // enter the section (the same as locking a mutex) - void WXCRITICAL_INLINE Enter(); + WXCRITICAL_INLINE void Enter(); // leave the critical section (same as unlocking a mutex) - void WXCRITICAL_INLINE Leave(); + WXCRITICAL_INLINE void Leave(); private: // no assignment operator nor copy ctor wxCriticalSection(const wxCriticalSection&); wxCriticalSection& operator=(const wxCriticalSection&); -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXPM__) wxCriticalSectionInternal *m_critsect; #else // !MSW wxMutex m_mutex; @@ -301,7 +301,7 @@ public: // Returns true if the thread is running (not paused, not killed). bool IsRunning() const; // Returns true if the thread is suspended - bool IsPaused() const { return IsAlive() && !IsRunning(); } + bool IsPaused() const; // called when the thread exits - in the context of this thread // @@ -350,12 +350,26 @@ private: void WXDLLEXPORT wxMutexGuiEnter(); void WXDLLEXPORT wxMutexGuiLeave(); +// macros for entering/leaving critical sections which may be used without +// having to take them inside "#if wxUSE_THREADS" +#define wxENTER_CRIT_SECT(cs) (cs)->Enter() +#define wxLEAVE_CRIT_SECT(cs) (cs)->Leave() +#define wxCRIT_SECT_LOCKER(name, cs) wxCriticalSectionLocker name(*cs) + #else // !wxUSE_THREADS +#include "wx/defs.h" // for WXDLLEXPORT + // no thread support inline void WXDLLEXPORT wxMutexGuiEnter() { } inline void WXDLLEXPORT wxMutexGuiLeave() { } +// macros for entering/leaving critical sections which may be used without +// having to take them inside "#if wxUSE_THREADS" +#define wxENTER_CRIT_SECT(cs) +#define wxLEAVE_CRIT_SECT(cs) +#define wxCRIT_SECT_LOCKER(name, cs) + #endif // wxUSE_THREADS // automatically unlock GUI mutex in dtor @@ -370,7 +384,7 @@ public: // implementation only until the end of file // ----------------------------------------------------------------------------- #if wxUSE_THREADS -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXPM__) // unlock GUI if there are threads waiting for and lock it back when // there are no more of them - should be called periodically by the main // thread