Added wxCriticalSection::TryEnter() method.
This is similar to wxMutex::TryLock() and useful for the same reasons. Closes #13638. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69883 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -249,6 +249,9 @@ public:
|
||||
// enter the section (the same as locking a mutex)
|
||||
wxCRITSECT_INLINE void Enter();
|
||||
|
||||
// try to enter the section (the same as trying to lock a mutex)
|
||||
wxCRITSECT_INLINE bool TryEnter();
|
||||
|
||||
// leave the critical section (same as unlocking a mutex)
|
||||
wxCRITSECT_INLINE void Leave();
|
||||
|
||||
@@ -291,6 +294,7 @@ private:
|
||||
inline wxCriticalSection::~wxCriticalSection() { }
|
||||
|
||||
inline void wxCriticalSection::Enter() { (void)m_mutex.Lock(); }
|
||||
inline bool wxCriticalSection::TryEnter() { return m_mutex.TryLock() == wxMUTEX_NO_ERROR; }
|
||||
inline void wxCriticalSection::Leave() { (void)m_mutex.Unlock(); }
|
||||
#endif // wxCRITSECT_IS_MUTEX
|
||||
|
||||
|
Reference in New Issue
Block a user