Timer that mimics the behavior of Qt timers.
More...
#include <TimerScheduler.hpp>
|
| | Timer (TimerScheduler &scheduler) |
| |
| | ~Timer () |
| |
| | Timer (const Timer &)=delete |
| |
| Timer & | operator= (const Timer &)=delete |
| |
| | Timer (Timer &&)=delete |
| |
| Timer & | operator= (Timer &&)=delete |
| |
| template<class Rep, class Period> |
| void | set_interval (std::chrono::duration< Rep, Period > interval) noexcept |
| | Sets the interval used by the timer.
|
| |
| std::chrono::milliseconds | interval () const noexcept |
| | Returns the currently configured interval.
|
| |
| void | start () |
| | Starts the timer using the previously configured interval.
|
| |
| template<class Rep, class Period> |
| void | start (std::chrono::duration< Rep, Period > interval) |
| | Starts the timer with the specified interval.
|
| |
| void | stop () |
| | Stops the timer.
|
| |
| void | stop_and_wait () |
| | Stops the timer and waits until an active callback finishes.
|
| |
| void | set_single_shot (bool is_single_shot) noexcept |
| | Sets whether the timer should fire only once.
|
| |
| bool | is_single_shot () const noexcept |
| | Returns true if the timer fires only once.
|
| |
| bool | is_active () const noexcept |
| | Returns true if the timer is active.
|
| |
| bool | is_running () const noexcept |
| | Returns true if the timer callback is being executed.
|
| |
| void | set_callback (Callback callback) |
| | Sets the callback that should be invoked when the timer fires.
|
| |
|
| template<class Rep, class Period> |
| static void | single_shot (TimerScheduler &scheduler, std::chrono::duration< Rep, Period > interval, Callback callback) |
| | Creates a single-shot timer that invokes the callback once.
|
| |
Timer that mimics the behavior of Qt timers.
Definition at line 176 of file TimerScheduler.hpp.
◆ Callback
◆ Timer() [1/3]
◆ ~Timer()
| time_shield::Timer::~Timer |
( |
| ) |
|
|
inline |
◆ Timer() [2/3]
| time_shield::Timer::Timer |
( |
const Timer & | | ) |
|
|
delete |
◆ Timer() [3/3]
| time_shield::Timer::Timer |
( |
Timer && | | ) |
|
|
delete |
◆ interval()
| std::chrono::milliseconds time_shield::Timer::interval |
( |
| ) |
const |
|
inlinenoexcept |
◆ is_active()
| bool time_shield::Timer::is_active |
( |
| ) |
const |
|
inlinenoexcept |
◆ is_running()
| bool time_shield::Timer::is_running |
( |
| ) |
const |
|
inlinenoexcept |
◆ is_single_shot()
| bool time_shield::Timer::is_single_shot |
( |
| ) |
const |
|
inlinenoexcept |
◆ operator=() [1/2]
| Timer & time_shield::Timer::operator= |
( |
const Timer & | | ) |
|
|
delete |
◆ operator=() [2/2]
| Timer & time_shield::Timer::operator= |
( |
Timer && | | ) |
|
|
delete |
◆ set_callback()
| void time_shield::Timer::set_callback |
( |
Callback | callback | ) |
|
|
inline |
Sets the callback that should be invoked when the timer fires.
Definition at line 595 of file TimerScheduler.hpp.
◆ set_interval()
template<class Rep, class Period>
| void time_shield::Timer::set_interval |
( |
std::chrono::duration< Rep, Period > | interval | ) |
|
|
noexcept |
Sets the interval used by the timer.
Negative durations are clamped to zero. An interval of zero means the timer is rescheduled immediately after firing.
Definition at line 541 of file TimerScheduler.hpp.
◆ set_single_shot()
| void time_shield::Timer::set_single_shot |
( |
bool | is_single_shot | ) |
|
|
inlinenoexcept |
◆ single_shot()
template<class Rep, class Period>
| void time_shield::Timer::single_shot |
( |
TimerScheduler & | scheduler, |
|
|
std::chrono::duration< Rep, Period > | interval, |
|
|
Callback | callback ) |
|
static |
Creates a single-shot timer that invokes the callback once.
The helper keeps the timer alive until the callback finishes.
Definition at line 601 of file TimerScheduler.hpp.
◆ start() [1/2]
| void time_shield::Timer::start |
( |
| ) |
|
|
inline |
Starts the timer using the previously configured interval.
Definition at line 554 of file TimerScheduler.hpp.
◆ start() [2/2]
template<class Rep, class Period>
| void time_shield::Timer::start |
( |
std::chrono::duration< Rep, Period > | interval | ) |
|
◆ stop()
| void time_shield::Timer::stop |
( |
| ) |
|
|
inline |
Stops the timer.
The operation is non-blocking: the method does not wait for a running callback to finish. Use stop_and_wait() to synchronously wait for completion.
Definition at line 566 of file TimerScheduler.hpp.
◆ stop_and_wait()
| void time_shield::Timer::stop_and_wait |
( |
| ) |
|
|
inline |
Stops the timer and waits until an active callback finishes.
Must not be called from inside the timer callback itself.
Definition at line 570 of file TimerScheduler.hpp.
◆ m_scheduler
◆ m_state
The documentation for this class was generated from the following file: