From 8e9d28e7e09bf1cf93b9d57256664b559ae07aab Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 9 Mar 2021 17:21:31 +0100 Subject: [PATCH] Change wait_for interface for wait_until in circular_buffer --- lib/include/srslte/adt/circular_buffer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/include/srslte/adt/circular_buffer.h b/lib/include/srslte/adt/circular_buffer.h index e6df1cd47..84c3f40d5 100644 --- a/lib/include/srslte/adt/circular_buffer.h +++ b/lib/include/srslte/adt/circular_buffer.h @@ -219,7 +219,7 @@ public: pop_(obj, true); return obj; } - bool pop_wait_for(T& obj, const std::chrono::microseconds& duration) { return pop_(obj, true, &duration); } + bool pop_wait_until(T& obj, const std::chrono::system_clock::time_point& until) { return pop_(obj, true, &until); } void clear() { std::lock_guard lock(mutex); @@ -326,7 +326,7 @@ protected: return {}; } - bool pop_(T& obj, bool block, const std::chrono::microseconds* duration = nullptr) + bool pop_(T& obj, bool block, const std::chrono::system_clock::time_point* until = nullptr) { std::unique_lock lock(mutex); if (not active) { @@ -337,10 +337,10 @@ protected: return false; } nof_waiting++; - if (duration == nullptr) { + if (until == nullptr) { cvar_empty.wait(lock, [this]() { return not circ_buffer.empty() or not active; }); } else { - cvar_empty.wait_for(lock, *duration, [this]() { return not circ_buffer.empty() or not active; }); + cvar_empty.wait_until(lock, *until, [this]() { return not circ_buffer.empty() or not active; }); } nof_waiting--; if (circ_buffer.empty()) {