X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8ec9749cf1d2b65efdb076f8696e454843bb9b8..724852daae642bbba3e02e11e972e747ed106190:/include/wx/thread.h?ds=sidebyside diff --git a/include/wx/thread.h b/include/wx/thread.h index e7dcf882ac..a8346d20e0 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -22,11 +22,6 @@ #if wxUSE_THREADS -// Windows headers define it -#ifdef Yield - #undef Yield -#endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -209,25 +204,33 @@ private: // in order to avoid any overhead under platforms where critical sections are // just mutexes make all wxCriticalSection class functions inline -#if !defined(__WXMSW__) && !defined(__WXMAC__) +#if !defined(__WXMSW__) #define wxCRITSECT_IS_MUTEX 1 - #define wxCRITSECT_INLINE inline + #define wxCRITSECT_INLINE WXEXPORT inline #else // MSW #define wxCRITSECT_IS_MUTEX 0 #define wxCRITSECT_INLINE #endif // MSW/!MSW +enum wxCriticalSectionType +{ + // recursive critical section + wxCRITSEC_DEFAULT, + + // non-recursive critical section + wxCRITSEC_NON_RECURSIVE +}; + // you should consider wxCriticalSectionLocker whenever possible instead of // directly working with wxCriticalSection class - it is safer class WXDLLIMPEXP_BASE wxCriticalSection { public: // ctor & dtor - wxCRITSECT_INLINE wxCriticalSection(); + wxCRITSECT_INLINE wxCriticalSection( wxCriticalSectionType critSecType = wxCRITSEC_DEFAULT ); wxCRITSECT_INLINE ~wxCriticalSection(); - // enter the section (the same as locking a mutex) wxCRITSECT_INLINE void Enter(); @@ -261,8 +264,6 @@ private: wxCritSectBuffer m_buffer; }; -#elif defined(__WXMAC__) - void *m_critRegion ; #endif // Unix&OS2/Win32 DECLARE_NO_COPY_CLASS(wxCriticalSection) @@ -270,7 +271,8 @@ private: #if wxCRITSECT_IS_MUTEX // implement wxCriticalSection using mutexes - inline wxCriticalSection::wxCriticalSection() { } + inline wxCriticalSection::wxCriticalSection( wxCriticalSectionType critSecType ) + : m_mutex( critSecType == wxCRITSEC_DEFAULT ? wxMUTEX_RECURSIVE : wxMUTEX_DEFAULT ) { } inline wxCriticalSection::~wxCriticalSection() { } inline void wxCriticalSection::Enter() { (void)m_mutex.Lock(); } @@ -452,7 +454,7 @@ public: // Sleep during the specified period of time in milliseconds // - // NB: at least under MSW worker threads can not call ::wxSleep()! + // This is the same as wxMilliSleep(). static void Sleep(unsigned long milliseconds); // get the number of system CPUs - useful with SetConcurrency() @@ -779,7 +781,7 @@ public: #if wxUSE_THREADS -#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__OS2__) || defined(__EMX__) +#if defined(__WXMSW__) || defined(__OS2__) || defined(__EMX__) // 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 @@ -794,7 +796,7 @@ public: // return true if the main thread is waiting for some other to terminate: // wxApp then should block all "dangerous" messages extern bool WXDLLIMPEXP_BASE wxIsWaitingForThread(); -#endif // MSW, Mac, OS/2 +#endif // MSW, OS/2 #endif // wxUSE_THREADS