diff --git a/src/IOThread.h b/src/IOThread.h index 3449ae2..62c7cf9 100644 --- a/src/IOThread.h +++ b/src/IOThread.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -61,7 +61,11 @@ public: while (it != outputBuffers.end()) { + //careful here: take care of reading the use_count directly + //through the iterator, else it's value is wrong if a temp variable + //is used. long use = it->ptr.use_count(); + //1. If we encounter a shared_ptr with a use count of 0, this //is a bug since it is supposed to be at least 1, because it is referenced here. //in this case, purge it from here and trace. @@ -133,13 +137,14 @@ private: //name of the buffer cache kind std::string bufferId; - //the ReBuffer cache - std::vector< ReBufferAge < ReBufferPtr > > outputBuffers; + //the ReBuffer cache: use a std:deque to also release + //memory when ReBufferPtr are GCed. + std::deque< ReBufferAge < ReBufferPtr > > outputBuffers; - typedef typename std::vector< ReBufferAge < ReBufferPtr > >::iterator outputBuffersI; + typedef typename std::deque< ReBufferAge < ReBufferPtr > >::iterator outputBuffersI; //mutex protecting access to outputBuffers. - mutable std::mutex m_mutex; + std::mutex m_mutex; }; @@ -183,7 +188,7 @@ protected: std::map output_queues; //this protects against concurrent changes in input/output bindings: get/set/Input/OutPutQueue - mutable std::mutex m_queue_bindings_mutex; + std::mutex m_queue_bindings_mutex; //true when a termination is ordered std::atomic_bool stopping; diff --git a/src/demod/DemodulatorInstance.h b/src/demod/DemodulatorInstance.h index a5be9d1..bb4fd52 100644 --- a/src/demod/DemodulatorInstance.h +++ b/src/demod/DemodulatorInstance.h @@ -139,7 +139,7 @@ private: DemodulatorThreadControlCommandQueue *threadQueueControl; //protects child thread creation and termination - mutable std::mutex m_thread_control_mutex; + std::mutex m_thread_control_mutex; std::atomic label; // // User editable buffer, 16 bit string. diff --git a/src/demod/DemodulatorMgr.h b/src/demod/DemodulatorMgr.h index e6887f1..d9db719 100644 --- a/src/demod/DemodulatorMgr.h +++ b/src/demod/DemodulatorMgr.h @@ -93,7 +93,7 @@ private: //because of the usage of public re-entrant methods std::recursive_mutex demods_busy; - mutable std::mutex deleted_demods_busy; + std::mutex deleted_demods_busy; std::map lastModemSettings; std::map outputDevices; diff --git a/src/demod/DemodulatorThread.h b/src/demod/DemodulatorThread.h index 5152364..d9c9a5a 100644 --- a/src/demod/DemodulatorThread.h +++ b/src/demod/DemodulatorThread.h @@ -68,5 +68,5 @@ protected: DemodulatorThreadControlCommandQueue *threadQueueControl = nullptr; //protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr) - mutable std::mutex m_mutexAudioVisOutputQueue; + std::mutex m_mutexAudioVisOutputQueue; };