From 3d125af2ed660fef3eaf0cf2ba1f55f0f069566a Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 1 Jan 2022 07:38:06 +0100 Subject: [PATCH] refactor(DoTask): formatting and naming --- do_task.cpp | 9 +++++---- do_task.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/do_task.cpp b/do_task.cpp index 1334e37..067e36e 100644 --- a/do_task.cpp +++ b/do_task.cpp @@ -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 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(); } } diff --git a/do_task.h b/do_task.h index e13a029..e54da45 100644 --- a/do_task.h +++ b/do_task.h @@ -11,7 +11,7 @@ namespace fortuna { class DoTask { private: std::timed_mutex do_sleep; - std::thread threadie; + std::thread th; public: ~DoTask() noexcept;