From 01e4f666c251c5e1fab9e2e49ba3174a37ebce51 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Thu, 12 Jan 2023 21:26:12 +0100 Subject: [PATCH] FIX: fixed the way of getting data from the threadsafequeue --- include/WHISPER/threadSafeQueue.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/WHISPER/threadSafeQueue.hpp b/include/WHISPER/threadSafeQueue.hpp index f370efb..28f075b 100644 --- a/include/WHISPER/threadSafeQueue.hpp +++ b/include/WHISPER/threadSafeQueue.hpp @@ -26,6 +26,21 @@ namespace WHISPER { // Get the front element. // If the queue is empty, wait till a element is avaiable. + bool get(T &val) + { + std::unique_lock lock(m); + if (!q.empty()) { + + // auto tmp = q.front(); + val = std::move(q.front()); + q.pop(); + return true; + }else { + return false; + } + } + + [[deprecated]] T get(void) { std::unique_lock lock(m);