mirror of
https://github.com/polybar/polybar.git
synced 2024-10-27 05:23:39 -04:00
fix: Use native wait timeout
This commit is contained in:
parent
5f0a90722a
commit
2b39fcd7dd
1 changed files with 2 additions and 10 deletions
|
@ -154,9 +154,9 @@ namespace modules
|
||||||
|
|
||||||
void stop()
|
void stop()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<concurrency::SpinLock> lck(this->broadcast_lock);
|
||||||
log_trace(name());
|
log_trace(name());
|
||||||
this->wakeup();
|
this->wakeup();
|
||||||
std::lock_guard<concurrency::SpinLock> lck(this->broadcast_lock);
|
|
||||||
this->enable(false);
|
this->enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,15 +194,7 @@ namespace modules
|
||||||
void sleep(std::chrono::duration<double> sleep_duration)
|
void sleep(std::chrono::duration<double> sleep_duration)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lck(this->sleep_lock);
|
std::unique_lock<std::mutex> lck(this->sleep_lock);
|
||||||
std::thread sleep_thread([&]{
|
this->sleep_handler.wait_for(lck, sleep_duration);
|
||||||
auto start = std::chrono::system_clock::now();
|
|
||||||
while ((std::chrono::system_clock::now() - start) < sleep_duration) {
|
|
||||||
std::this_thread::sleep_for(50ms);
|
|
||||||
}
|
|
||||||
this->wakeup();
|
|
||||||
});
|
|
||||||
sleep_thread.detach();
|
|
||||||
this->sleep_handler.wait(lck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wakeup()
|
void wakeup()
|
||||||
|
|
Loading…
Reference in a new issue