X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac9e3f1f1c4ba844c5598aa577e51d128dd5921b..89b4415803685b243946e4941522be8232621fa6:/include/wx/thread.h?ds=sidebyside diff --git a/include/wx/thread.h b/include/wx/thread.h index 53e177f515..a8346d20e0 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -204,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__) || wxOSX_USE_COCOA_OR_IPHONE ) +#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(); @@ -256,8 +264,6 @@ private: wxCritSectBuffer m_buffer; }; -#elif defined(__WXMAC__) - void *m_critRegion ; #endif // Unix&OS2/Win32 DECLARE_NO_COPY_CLASS(wxCriticalSection) @@ -265,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(); } @@ -774,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 @@ -789,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