diff options
author | MacroFake <falke.marco@gmail.com> | 2022-04-30 10:24:24 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-07-13 15:20:49 +0200 |
commit | fa3b3cb9b5d944d34b1d5ac3e102ac333482a475 (patch) | |
tree | 9a338b793380212c0972c031681e59bb03a956b1 /src/threadinterrupt.h | |
parent | 1d89fc695a3aeb3e3dcadf371b7667572b38c836 (diff) | |
download | bitcoin-fa3b3cb9b5d944d34b1d5ac3e102ac333482a475.tar.xz |
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.h')
-rw-r--r-- | src/threadinterrupt.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/threadinterrupt.h b/src/threadinterrupt.h index 992016b4f6..363aab39ce 100644 --- a/src/threadinterrupt.h +++ b/src/threadinterrupt.h @@ -19,13 +19,12 @@ class CThreadInterrupt { public: + using Clock = std::chrono::steady_clock; CThreadInterrupt(); explicit operator bool() const; void operator()() EXCLUSIVE_LOCKS_REQUIRED(!mut); void reset(); - bool sleep_for(std::chrono::milliseconds rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut); - bool sleep_for(std::chrono::seconds rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut); - bool sleep_for(std::chrono::minutes rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut); + bool sleep_for(Clock::duration rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut); private: std::condition_variable cond; |