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:
vsonnier
2017-05-25 09:32:27 +02:00
parent 77a82e1617
commit 9b0ce69e8f
12 changed files with 65 additions and 25 deletions
+6 -1
View File
@@ -8,6 +8,9 @@
#include <vector>
#include <deque>
//50 ms
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
SDRPostThread::SDRPostThread() : IOThread(), buffers("SDRPostThreadBuffers"), visualDataBuffers("SDRPostThreadVisualDataBuffers"), frequency(0) {
iqDataInQueue = NULL;
iqDataOutQueue = NULL;
@@ -185,7 +188,9 @@ void SDRPostThread::run() {
while (!stopping) {
SDRThreadIQDataPtr data_in;
iqDataInQueue->pop(data_in);
if (!iqDataInQueue->pop(data_in, HEARTBEAT_CHECK_PERIOD_MICROS)) {
continue;
}
// std::lock_guard < std::mutex > lock(data_in->m_mutex);
std::lock_guard < std::mutex > lock(busy_demod);