From 11e76a417704074e8f6e37747197d27fa181cc81 Mon Sep 17 00:00:00 2001 From: marcelb Date: Wed, 27 Mar 2024 16:54:53 +0100 Subject: [PATCH] Condition varable for stoped rotating --- lib/rotor.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rotor.hpp b/lib/rotor.hpp index 2614580..c832df7 100644 --- a/lib/rotor.hpp +++ b/lib/rotor.hpp @@ -93,8 +93,10 @@ class rotor { { unique_lock te_l(te_m); - te_cv.wait(te_l, [this]{ return !tcores.empty(); }); - // calc_next(); + te_cv.wait(te_l, [this]{ return !tcores.empty() || rotating; }); + if (!rotating) { + break; + } next_tc = min_element( tcores.begin(), tcores.end(), [](shared_ptr a, shared_ptr b ) { @@ -131,7 +133,7 @@ class rotor { void remove(vector>::iterator it) { lock_guard lock(te_m); tcores.erase(it); - te_cv.notify_one(); + // te_cv.notify_one(); } public: