This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
2021-12-12 18:42:47 +01:00
|
|
|
#ifndef FORTUNA_DO_TASK_H
|
|
|
|
#define FORTUNA_DO_TASK_H
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <functional>
|
|
|
|
#include <mutex>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
namespace fortuna {
|
|
|
|
|
|
|
|
class DoTask {
|
|
|
|
private:
|
2022-01-21 02:54:15 +01:00
|
|
|
std::recursive_timed_mutex mtx_do_sleep;
|
2022-01-01 07:38:06 +01:00
|
|
|
std::thread th;
|
2022-01-10 04:25:03 +01:00
|
|
|
|
2021-12-12 18:42:47 +01:00
|
|
|
public:
|
2022-01-09 11:58:38 +01:00
|
|
|
DoTask() noexcept = default;
|
2021-12-12 18:42:47 +01:00
|
|
|
~DoTask() noexcept;
|
|
|
|
|
|
|
|
auto thread_pls(const std::chrono::seconds& interval,
|
2022-01-10 04:25:03 +01:00
|
|
|
std::function<void()> callback) -> void;
|
2021-12-12 18:42:47 +01:00
|
|
|
auto die_pls() -> void;
|
|
|
|
|
|
|
|
}; // class DoTask
|
|
|
|
|
|
|
|
} // namespace fortuna
|
|
|
|
|
2022-01-10 04:25:03 +01:00
|
|
|
#endif // FORTUNA_DO_TASK_H
|