mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-02 14:04:47 -04:00
Use the nuclear option to solve the hung problem:
Besides deadlocks, a thread can in theory get stuck in a blocking pop(), not seeing the stopping flag in particular. So assure liveness by making all pop() timed pop.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
#include <algorithm>
|
||||
#include <ThreadBlockingQueue.h>
|
||||
|
||||
//50 ms
|
||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||
|
||||
FFTDataDistributor::FFTDataDistributor() : outputBuffers("FFTDataDistributorBuffers"), fftSize(DEFAULT_FFT_SIZE), linesPerSecond(DEFAULT_WATERFALL_LPS), lineRateAccum(0.0) {
|
||||
|
||||
}
|
||||
@@ -29,7 +32,10 @@ void FFTDataDistributor::process() {
|
||||
return;
|
||||
}
|
||||
DemodulatorThreadIQDataPtr inp;
|
||||
input->pop(inp);
|
||||
|
||||
if (!input->pop(inp, HEARTBEAT_CHECK_PERIOD_MICROS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inp) {
|
||||
//Settings have changed, set new values and dump all previous samples stored in inputBuffer:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "SpectrumVisualProcessor.h"
|
||||
#include "CubicSDR.h"
|
||||
|
||||
//50 ms
|
||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||
|
||||
SpectrumVisualProcessor::SpectrumVisualProcessor() : outputBuffers("SpectrumVisualProcessorBuffers") {
|
||||
lastInputBandwidth = 0;
|
||||
@@ -194,7 +196,9 @@ void SpectrumVisualProcessor::process() {
|
||||
|
||||
DemodulatorThreadIQDataPtr iqData;
|
||||
|
||||
input->pop(iqData);
|
||||
if (!input->pop(iqData, HEARTBEAT_CHECK_PERIOD_MICROS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!iqData) {
|
||||
return;
|
||||
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
//available outputs, previously set by attachOutput().
|
||||
//* \param[in] timeout The number of microseconds to wait to push an item in each one of the outputs, 0(default) means indefinite wait.
|
||||
//* \param[in] errorMessage an error message written on std::cout in case pf push timeout.
|
||||
void distribute(OutputDataTypePtr item, std::uint64_t timeout = BLOCKING_INFINITE_TIMEOUT, const char* errorMessage = "") {
|
||||
void distribute(OutputDataTypePtr item, std::uint64_t timeout = BLOCKING_INFINITE_TIMEOUT, const char* errorMessage = nullptr) {
|
||||
|
||||
std::lock_guard < std::recursive_mutex > busy_lock(busy_update);
|
||||
//We will try to distribute 'output' among all 'outputs',
|
||||
|
||||
Reference in New Issue
Block a user