|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Owns one scheduled timer and cancels it when destroyed. Move-only. More...
#include <scheduler.hpp>
Public Member Functions | |
| TimerHandle ()=default | |
| A handle that owns no timer. | |
| TimerHandle (std::function< void()> cancel, std::function< bool()> isScheduled={}) | |
| Takes ownership of a timer through the function that cancels it. | |
| ~TimerHandle () | |
| Cancels the timer, if this handle still owns one. | |
| TimerHandle (TimerHandle const &)=delete | |
| TimerHandle & | operator= (TimerHandle const &)=delete |
| TimerHandle (TimerHandle &&other) noexcept | |
Takes over other's timer; other then owns none. | |
| TimerHandle & | operator= (TimerHandle &&other) noexcept |
Cancels this handle's timer, then takes over other's. | |
| void | cancel () noexcept |
| Cancels the timer, if this handle still owns one. | |
| bool | active () const noexcept |
| Whether this handle still owns a scheduled timer. | |
Owns one scheduled timer and cancels it when destroyed. Move-only.
A scheduler hands it two functions: one that cancels the timer and one that says whether the timer is still scheduled. So active() turns false once a one-shot timer has fired, and cancelling a fired timer does nothing.
Definition at line 19 of file scheduler.hpp.
|
inlineexplicit |
Takes ownership of a timer through the function that cancels it.
| cancel | Cancels the timer; called at most once. It must tolerate a timer that has already fired or whose scheduler is gone. |
| isScheduled | Whether the timer is still scheduled: false once a one-shot timer has fired or its scheduler is gone. Empty means the handle cannot tell, and active() stays true until cancel(). |
Definition at line 29 of file scheduler.hpp.
|
inline |
Cancels the timer, if this handle still owns one.
Definition at line 33 of file scheduler.hpp.
|
inlinenoexcept |
Takes over other's timer; other then owns none.
| other | The handle to move from. |
Definition at line 40 of file scheduler.hpp.
|
inlinenoexcept |
Cancels this handle's timer, then takes over other's.
| other | The handle to move from. |
Definition at line 46 of file scheduler.hpp.
|
inlinenoexcept |
Cancels the timer, if this handle still owns one.
Definition at line 56 of file scheduler.hpp.
|
inlinenodiscardnoexcept |
Whether this handle still owns a scheduled timer.
Definition at line 71 of file scheduler.hpp.