8#include <BS_thread_pool.hpp>
9#include <entt/locator/locator.hpp>
13using namespace std::chrono_literals;
28 , m_callback {
nullptr}
39 , m_callback {
nullptr}
41 set(std::move(func), delay);
51 m_callback = std::move(func);
67 auto& tp = entt::locator<BS::light_thread_pool>::value();
73 std::this_thread::sleep_for(std::chrono::milliseconds(
m_delay));
79 std::this_thread::sleep_for(0.1ms);
void set(Timer::Function &&func, const std::uint32_t delay) noexcept
Run a function on a precision timer.
std::uint32_t m_delay
Current delay on timer.
void stop() noexcept
Stop timer.
void repeat(const bool repeat) noexcept
Make function repeat itself instead of running once.
bool paused() const noexcept
Is the timer paused?
Timer() noexcept
Constructor.
double m_time_passed
Time passed.
std::atomic_bool m_stopped
Is timer stopped.
Timer::Function m_callback
Callback function.
std::atomic_bool m_paused
Is timer paused.
std::future< void > m_handle
Thread running task.
void pause(const bool pause) noexcept
Pause the timer.
~Timer() noexcept
Destructor.
std::move_only_function< void(void)> Function
Timer callback type.
std::atomic_bool m_repeat
Is function repeating?
bool stopped() const noexcept
Is the timer finished?