// 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();
wxCritSectBuffer m_buffer;
};
-#elif defined(__WXMAC__)
- void *m_critRegion ;
#endif // Unix&OS2/Win32
DECLARE_NO_COPY_CLASS(wxCriticalSection)
#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(); }
#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
// 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