Asynchronous timer class.
More...
#include <Timer.hpp>
|
using | Function = std::move_only_function<void(void)> |
| Timer callback type.
|
|
|
| Timer () noexcept |
| Constructor.
|
|
| Timer (Timer::Function &&func, const std::uint32_t delay) noexcept |
| Set constructor.
|
|
| ~Timer () noexcept |
| Destructor.
|
|
void | set (Timer::Function &&func, const std::uint32_t delay) noexcept |
| Run a function on a precision timer.
|
|
void | repeat (const bool repeat) noexcept |
| Make function repeat itself instead of running once.
|
|
void | start () |
| 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 21 of file Timer.hpp.
◆ Function
◆ Timer() [1/3]
galaxy::async::Timer::Timer |
( |
| ) |
|
|
noexcept |
◆ Timer() [2/3]
galaxy::async::Timer::Timer |
( |
Timer::Function && | func, |
|
|
const std::uint32_t | delay ) |
|
noexcept |
Set constructor.
- Parameters
-
func | Function to call. |
delay | Delay until function is called. In milliseconds. |
Definition at line 32 of file Timer.cpp.
◆ ~Timer()
galaxy::async::Timer::~Timer |
( |
| ) |
|
|
noexcept |
◆ Timer() [3/3]
galaxy::async::Timer::Timer |
( |
const Timer & | | ) |
|
|
privatedelete |
◆ set()
void galaxy::async::Timer::set |
( |
Timer::Function && | func, |
|
|
const std::uint32_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 49 of file Timer.cpp.
◆ repeat()
void galaxy::async::Timer::repeat |
( |
const bool | repeat | ) |
|
|
noexcept |
Make function repeat itself instead of running once.
- Parameters
-
Definition at line 55 of file Timer.cpp.
◆ start()
void galaxy::async::Timer::start |
( |
| ) |
|
◆ stop()
void galaxy::async::Timer::stop |
( |
| ) |
|
|
noexcept |
◆ pause()
void galaxy::async::Timer::pause |
( |
const bool | pause | ) |
|
|
noexcept |
Pause the timer.
- Parameters
-
True | to pause, False to unpause. |
Definition at line 96 of file Timer.cpp.
◆ stopped()
bool galaxy::async::Timer::stopped |
( |
| ) |
const |
|
nodiscardnoexcept |
Is the timer finished?
- Returns
- True if timer is stopped (finished).
Definition at line 101 of file Timer.cpp.
◆ paused()
bool galaxy::async::Timer::paused |
( |
| ) |
const |
|
nodiscardnoexcept |
Is the timer paused?
- Returns
- True if timer is paused.
Definition at line 106 of file Timer.cpp.
◆ operator=()
Timer & galaxy::async::Timer::operator= |
( |
const Timer & | | ) |
|
|
privatedelete |
Copy assignment operator.
◆ m_stopped
std::atomic_bool galaxy::async::Timer::m_stopped |
|
private |
◆ m_paused
std::atomic_bool galaxy::async::Timer::m_paused |
|
private |
◆ m_repeat
std::atomic_bool galaxy::async::Timer::m_repeat |
|
private |
Is function repeating?
Definition at line 120 of file Timer.hpp.
◆ m_delay
std::uint32_t galaxy::async::Timer::m_delay |
|
private |
Current delay on timer.
Definition at line 125 of file Timer.hpp.
◆ m_time_passed
double galaxy::async::Timer::m_time_passed |
|
private |
◆ m_handle
std::future<void> galaxy::async::Timer::m_handle |
|
private |
Thread running task.
Definition at line 135 of file Timer.hpp.
◆ m_callback
Callback function.
Definition at line 140 of file Timer.hpp.
The documentation for this class was generated from the following files: