aboutsummaryrefslogtreecommitdiff
path: root/src/threadinterrupt.cpp
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-04-30 10:24:24 +0200
committerMacroFake <falke.marco@gmail.com>2022-07-13 15:20:49 +0200
commitfa3b3cb9b5d944d34b1d5ac3e102ac333482a475 (patch)
tree9a338b793380212c0972c031681e59bb03a956b1 /src/threadinterrupt.cpp
parent1d89fc695a3aeb3e3dcadf371b7667572b38c836 (diff)
Expose underlying clock in CThreadInterrupt
Overloading sleep_for is not needed, as * seconds and minutes can be converted to milliseconds by the compiler, not needing a duration_cast * std::condition_variable::wait_for will convert milliseconds to the duration type of the underlying clock So simply expose the clock.
Diffstat (limited to 'src/threadinterrupt.cpp')
-rw-r--r--src/threadinterrupt.cpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/threadinterrupt.cpp b/src/threadinterrupt.cpp
index 340106ed99..e28b447c1d 100644
--- a/src/threadinterrupt.cpp
+++ b/src/threadinterrupt.cpp
@@ -28,18 +28,8 @@ void CThreadInterrupt::operator()()
cond.notify_all();
}
-bool CThreadInterrupt::sleep_for(std::chrono::milliseconds rel_time)
+bool CThreadInterrupt::sleep_for(Clock::duration rel_time)
{
WAIT_LOCK(mut, lock);
return !cond.wait_for(lock, rel_time, [this]() { return flag.load(std::memory_order_acquire); });
}
-
-bool CThreadInterrupt::sleep_for(std::chrono::seconds rel_time)
-{
- return sleep_for(std::chrono::duration_cast<std::chrono::milliseconds>(rel_time));
-}
-
-bool CThreadInterrupt::sleep_for(std::chrono::minutes rel_time)
-{
- return sleep_for(std::chrono::duration_cast<std::chrono::milliseconds>(rel_time));
-}