diff --git a/src/IOThread.h b/src/IOThread.h index fd8c1d1..eb4e94d 100644 --- a/src/IOThread.h +++ b/src/IOThread.h @@ -21,21 +21,27 @@ struct map_string_less : public std::binary_function lock(m_mutex); + refCount = rc; } void decRefCount() { - refCount.store(refCount.load()-1); + std::lock_guard < std::recursive_mutex > lock(m_mutex); + refCount--; } int getRefCount() { - return refCount.load(); + std::lock_guard < std::recursive_mutex > lock(m_mutex); + return refCount; } protected: - std::atomic_int refCount; + //this is a basic mutex for all ReferenceCounter derivatives operations INCLUDING the counter itself for consistency ! + mutable std::recursive_mutex m_mutex; + +private: + int refCount; }; diff --git a/src/audio/AudioThread.h b/src/audio/AudioThread.h index 5712288..57193f5 100644 --- a/src/audio/AudioThread.h +++ b/src/audio/AudioThread.h @@ -28,7 +28,7 @@ public: } ~AudioThreadInput() { - std::lock_guard < std::mutex > lock(m_mutex); + std::lock_guard < std::recursive_mutex > lock(m_mutex); } }; diff --git a/src/demod/DemodDefs.h b/src/demod/DemodDefs.h index b7d78a3..8dc5163 100644 --- a/src/demod/DemodDefs.h +++ b/src/demod/DemodDefs.h @@ -90,7 +90,7 @@ public: } ~DemodulatorThreadPostIQData() { - std::lock_guard < std::mutex > lock(m_mutex); + std::lock_guard < std::recursive_mutex > lock(m_mutex); } }; diff --git a/src/modules/modem/Modem.h b/src/modules/modem/Modem.h index 0172ea5..5a1c74e 100644 --- a/src/modules/modem/Modem.h +++ b/src/modules/modem/Modem.h @@ -32,7 +32,7 @@ public: } ~ModemIQData() { - std::lock_guard < std::mutex > lock(m_mutex); + std::lock_guard < std::recursive_mutex > lock(m_mutex); } };