From f301ed7e09ac982ff03a5b51b262a5e902d83f8a Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 12 Oct 2016 10:36:43 +0100 Subject: [PATCH] Added an isLocked() method to ReadWriteLock that checks whether ReadWriteLock is currently locked --- modules/juce_core/threads/juce_ReadWriteLock.cpp | 6 ++++++ modules/juce_core/threads/juce_ReadWriteLock.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/modules/juce_core/threads/juce_ReadWriteLock.cpp b/modules/juce_core/threads/juce_ReadWriteLock.cpp index e05c4277a8..50bc7644d0 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.cpp +++ b/modules/juce_core/threads/juce_ReadWriteLock.cpp @@ -148,3 +148,9 @@ void ReadWriteLock::exitWrite() const noexcept waitEvent.signal(); } } + +//============================================================================== +bool ReadWriteLock::isLocked() const noexcept +{ + return numWriters != 0; +} diff --git a/modules/juce_core/threads/juce_ReadWriteLock.h b/modules/juce_core/threads/juce_ReadWriteLock.h index 51937827d9..750efa32eb 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.h +++ b/modules/juce_core/threads/juce_ReadWriteLock.h @@ -127,6 +127,12 @@ public: */ void exitWrite() const noexcept; + //============================================================================== + /** Checks whether this object is locked. + + @returns true if the object is currently locked. + */ + bool isLocked() const noexcept; private: //==============================================================================