mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
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.
This commit is contained in:
parent
1d89fc695a
commit
fa3b3cb9b5
3 changed files with 4 additions and 14 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue