mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-03 06:24:49 -04:00
Use spin-locks for short-lived, non-recursive locking sequences
This commit is contained in:
@@ -39,13 +39,13 @@ void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBasePtr thread
|
||||
if (name == "AudioVisualOutput") {
|
||||
|
||||
//protects because it may be changed at runtime
|
||||
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
|
||||
std::lock_guard < SpinMutex > lock(m_mutexAudioVisOutputQueue);
|
||||
|
||||
audioVisOutputQueue = std::static_pointer_cast<DemodulatorThreadOutputQueue>(threadQueue);
|
||||
}
|
||||
|
||||
if (name == "AudioSink") {
|
||||
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
|
||||
std::lock_guard < SpinMutex > lock(m_mutexAudioVisOutputQueue);
|
||||
|
||||
audioSinkOutputQueue = std::static_pointer_cast<AudioThreadInputQueue>(threadQueue);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void DemodulatorThread::run() {
|
||||
//variable, and works with it with now on until the next while-turn.
|
||||
DemodulatorThreadOutputQueuePtr localAudioVisOutputQueue = nullptr;
|
||||
{
|
||||
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
|
||||
std::lock_guard < SpinMutex > lock(m_mutexAudioVisOutputQueue);
|
||||
localAudioVisOutputQueue = audioVisOutputQueue;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ void DemodulatorThread::run() {
|
||||
// Capture audioSinkOutputQueue state in a local variable
|
||||
DemodulatorThreadOutputQueuePtr localAudioSinkOutputQueue = nullptr;
|
||||
{
|
||||
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
|
||||
std::lock_guard < SpinMutex > lock(m_mutexAudioVisOutputQueue);
|
||||
localAudioSinkOutputQueue = audioSinkOutputQueue;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "DemodDefs.h"
|
||||
#include "AudioThread.h"
|
||||
#include "Modem.h"
|
||||
#include "SpinMutex.h"
|
||||
|
||||
#define DEMOD_VIS_SIZE 2048
|
||||
#define DEMOD_SIGNAL_MIN -30
|
||||
@@ -70,5 +71,5 @@ protected:
|
||||
DemodulatorThreadOutputQueuePtr audioSinkOutputQueue = nullptr;
|
||||
|
||||
//protects the audioVisOutputQueue dynamic binding change at runtime (in DemodulatorMgr)
|
||||
std::mutex m_mutexAudioVisOutputQueue;
|
||||
SpinMutex m_mutexAudioVisOutputQueue;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user