refactor(DoTask): formatting and naming
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
55cb3b6ec7
commit
3d125af2ed
|
@ -9,17 +9,18 @@ namespace fortuna {
|
|||
|
||||
auto DoTask::die_pls() -> void {
|
||||
do_sleep.unlock();
|
||||
threadie.join();
|
||||
th.join();
|
||||
}
|
||||
|
||||
auto DoTask::thread_pls(const std::chrono::seconds& interval,
|
||||
std::function<void()> callback) -> void {
|
||||
if (threadie.joinable()) {
|
||||
|
||||
if (th.joinable()) {
|
||||
die_pls();
|
||||
}
|
||||
|
||||
do_sleep.lock();
|
||||
threadie = std::thread([this, interval, callback = std::move(callback)] {
|
||||
th = std::thread([this, interval, callback = std::move(callback)] {
|
||||
while (!do_sleep.try_lock_for(interval)) {
|
||||
callback();
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ auto DoTask::thread_pls(const std::chrono::seconds& interval,
|
|||
}
|
||||
|
||||
DoTask::~DoTask() noexcept {
|
||||
if (threadie.joinable()) {
|
||||
if (th.joinable()) {
|
||||
die_pls();
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue