Asynchronous timer class.
More...
#include <Timer.hpp>
|
using | Function = std::move_only_function<void(void)> |
| Timer callback type.
|
|
|
| Timer () noexcept |
| Constructor.
|
|
| ~Timer () noexcept |
| Destructor.
|
|
void | set (Timer::Function &&func, const std::uint64_t delay) noexcept |
| Run a function on a precision timer.
|
|
void | start (const bool repeat=false) |
| Start timer.
|
|
void | stop () noexcept |
| Stop timer.
|
|
void | pause (const bool pause) noexcept |
| Pause the timer.
|
|
bool | stopped () const noexcept |
| Is the timer finished?
|
|
bool | paused () const noexcept |
| Is the timer paused?
|
|
Asynchronous timer class.
Definition at line 18 of file Timer.hpp.
◆ Function
◆ Timer() [1/2]
◆ ~Timer()
galaxy::Timer::~Timer |
( |
| ) |
|
|
noexcept |
◆ Timer() [2/2]
galaxy::Timer::Timer |
( |
const Timer & | | ) |
|
|
privatedelete |
◆ set()
void galaxy::Timer::set |
( |
Timer::Function && | func, |
|
|
const std::uint64_t | delay ) |
|
noexcept |
Run a function on a precision timer.
- Parameters
-
func | Function to call. |
delay | Delay until function is called. In milliseconds. |
Definition at line 34 of file Timer.cpp.
◆ start()
void galaxy::Timer::start |
( |
const bool | repeat = false | ) |
|
Start timer.
- Parameters
-
repeat | True to repeat. Defaults to false. |
Definition at line 40 of file Timer.cpp.
◆ stop()
void galaxy::Timer::stop |
( |
| ) |
|
|
noexcept |
◆ pause()
void galaxy::Timer::pause |
( |
const bool | pause | ) |
|
|
noexcept |
Pause the timer.
- Parameters
-
True | to pause, False to unpause. |
Definition at line 79 of file Timer.cpp.
◆ stopped()
bool galaxy::Timer::stopped |
( |
| ) |
const |
|
nodiscardnoexcept |
Is the timer finished?
- Returns
- True if timer is stopped (finished).
Definition at line 84 of file Timer.cpp.
◆ paused()
bool galaxy::Timer::paused |
( |
| ) |
const |
|
nodiscardnoexcept |
Is the timer paused?
- Returns
- True if timer is paused.
Definition at line 89 of file Timer.cpp.
◆ operator=()
Timer & galaxy::Timer::operator= |
( |
const Timer & | | ) |
|
|
privatedelete |
Copy assignment operator.
◆ m_started
std::atomic_bool galaxy::Timer::m_started |
|
private |
Has the timer been started.
Definition at line 94 of file Timer.hpp.
◆ m_paused
std::atomic_bool galaxy::Timer::m_paused |
|
private |
Is timer paused.
Definition at line 99 of file Timer.hpp.
◆ m_repeat
std::atomic_bool galaxy::Timer::m_repeat |
|
private |
◆ m_delay
std::uint64_t galaxy::Timer::m_delay |
|
private |
Current delay on timer.
Definition at line 109 of file Timer.hpp.
◆ m_handle
std::future<void> galaxy::Timer::m_handle |
|
private |
Thread running task.
Definition at line 114 of file Timer.hpp.
◆ m_callback
Callback function.
Definition at line 119 of file Timer.hpp.
The documentation for this class was generated from the following files: