8#include <BS_thread_pool.hpp>
9#include <entt/locator/locator.hpp>
15using namespace std::chrono_literals;
25 , m_callback {
nullptr}
36 m_callback = std::move(func);
48 auto& tp = entt::locator<BS::light_thread_pool>::value();
54 std::this_thread::sleep_for(std::chrono::milliseconds(
m_delay));
60 std::this_thread::sleep_for(0.01ms);
75 std::this_thread::sleep_for(0.01ms);
std::atomic_bool m_started
Has the timer been started.
void stop() noexcept
Stop timer.
std::future< void > m_handle
Thread running task.
std::atomic_bool m_repeat
Is timer looping.
Timer() noexcept
Constructor.
Timer::Function m_callback
Callback function.
void pause(const bool pause) noexcept
Pause the timer.
void start(const bool repeat=false)
Start timer.
std::atomic_bool m_paused
Is timer paused.
bool paused() const noexcept
Is the timer paused?
std::move_only_function< void(void)> Function
Timer callback type.
void set(Timer::Function &&func, const std::uint64_t delay) noexcept
Run a function on a precision timer.
std::uint64_t m_delay
Current delay on timer.
bool stopped() const noexcept
Is the timer finished?
~Timer() noexcept
Destructor.
bool is_work_done(const std::future< T > &task) noexcept
Check if an async thread has finished or not.