mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
Make ReBuffer also GC its own memory + cleanups:
- Use deque in ReBuffer instead of vector (as before) because it allows freeing its memory - Random cleanup: remove mutable when not needed.
This commit is contained in:
parent
3192ee0e71
commit
44cdfa8521
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <vector>
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -61,7 +61,11 @@ public:
|
|||||||
|
|
||||||
while (it != outputBuffers.end()) {
|
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();
|
long use = it->ptr.use_count();
|
||||||
|
|
||||||
//1. If we encounter a shared_ptr with a use count of 0, this
|
//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.
|
//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.
|
//in this case, purge it from here and trace.
|
||||||
@ -133,13 +137,14 @@ private:
|
|||||||
//name of the buffer cache kind
|
//name of the buffer cache kind
|
||||||
std::string bufferId;
|
std::string bufferId;
|
||||||
|
|
||||||
//the ReBuffer cache
|
//the ReBuffer cache: use a std:deque to also release
|
||||||
std::vector< ReBufferAge < ReBufferPtr > > outputBuffers;
|
//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.
|
//mutex protecting access to outputBuffers.
|
||||||
mutable std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -183,7 +188,7 @@ protected:
|
|||||||
std::map<std::string, ThreadQueueBase *, map_string_less> output_queues;
|
std::map<std::string, ThreadQueueBase *, map_string_less> output_queues;
|
||||||
|
|
||||||
//this protects against concurrent changes in input/output bindings: get/set/Input/OutPutQueue
|
//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
|
//true when a termination is ordered
|
||||||
std::atomic_bool stopping;
|
std::atomic_bool stopping;
|
||||||
|
@ -139,7 +139,7 @@ private:
|
|||||||
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
||||||
|
|
||||||
//protects child thread creation and termination
|
//protects child thread creation and termination
|
||||||
mutable std::mutex m_thread_control_mutex;
|
std::mutex m_thread_control_mutex;
|
||||||
|
|
||||||
std::atomic<std::string *> label; //
|
std::atomic<std::string *> label; //
|
||||||
// User editable buffer, 16 bit string.
|
// User editable buffer, 16 bit string.
|
||||||
|
@ -93,7 +93,7 @@ private:
|
|||||||
//because of the usage of public re-entrant methods
|
//because of the usage of public re-entrant methods
|
||||||
std::recursive_mutex demods_busy;
|
std::recursive_mutex demods_busy;
|
||||||
|
|
||||||
mutable std::mutex deleted_demods_busy;
|
std::mutex deleted_demods_busy;
|
||||||
|
|
||||||
std::map<std::string, ModemSettings> lastModemSettings;
|
std::map<std::string, ModemSettings> lastModemSettings;
|
||||||
std::map<int,RtAudio::DeviceInfo> outputDevices;
|
std::map<int,RtAudio::DeviceInfo> outputDevices;
|
||||||
|
@ -68,5 +68,5 @@ protected:
|
|||||||
DemodulatorThreadControlCommandQueue *threadQueueControl = nullptr;
|
DemodulatorThreadControlCommandQueue *threadQueueControl = nullptr;
|
||||||
|
|
||||||
//protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr)
|
//protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr)
|
||||||
mutable std::mutex m_mutexAudioVisOutputQueue;
|
std::mutex m_mutexAudioVisOutputQueue;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user