Timeout
Timeout
#include <icy/timeout.h>class TimeoutDefined in src/base/include/icy/timeout.h:32
Subclassed by:
TimedToken
Timeout counter which expires after a given delay. Delay is specified in milliseconds.
List of all members
| Name | Kind | Owner |
|---|---|---|
Timeout | function | Declared here |
Timeout | function | Declared here |
Timeout | function | Declared here |
~Timeout | function | Declared here |
running | function | Declared here |
start | function | Declared here |
stop | function | Declared here |
reset | function | Declared here |
remaining | function | Declared here |
expired | function | Declared here |
setDelay | function | Declared here |
delay | function | Declared here |
operator= | function | Declared here |
operator= | function | Declared here |
_startAt | variable | Declared here |
_delay | variable | Declared here |
_running | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
Timeout | Constructs a Timeout with the given delay. | |
Timeout | Copy constructor. | |
Timeout noexcept | Defaulted constructor. | |
bool | running const | Returns true if the timer is currently running. |
void | start | Starts (or restarts) the timer, recording the current time as the start point. |
void | stop | Stops the timer without resetting it. expired() will return false after this call. |
void | reset | Restarts the timer from now, equivalent to calling start(). |
long | remaining const | Returns the number of milliseconds remaining before expiry. Returns 0 if already expired, or the full delay if not running. |
bool | expired const | Returns true if the timer is running and the delay has fully elapsed. |
void | setDelay inline | Sets the expiry delay without restarting the timer. |
long | delay const inline | Returns the configured delay in milliseconds. |
Timeout & | operator= | Copy assignment operator. |
Timeout
Timeout(long delay = 0, bool autoStart = false)Defined in src/base/include/icy/timeout.h:38
Constructs a Timeout with the given delay.
Parameters
delayExpiry duration in milliseconds (default: 0).autoStartIf true, starts the timer immediately on construction.
Timeout
Timeout(const Timeout & src)Defined in src/base/include/icy/timeout.h:42
Copy constructor.
Parameters
srcSource Timeout to copy state from.
Timeout
noexcept
Timeout(Timeout && src) noexcept = defaultDefined in src/base/include/icy/timeout.h:44
Defaulted constructor.
running
const
bool running() constDefined in src/base/include/icy/timeout.h:49
Returns true if the timer is currently running.
Returns
true if start() has been called and stop() has not.
start
void start()Defined in src/base/include/icy/timeout.h:52
Starts (or restarts) the timer, recording the current time as the start point.
stop
void stop()Defined in src/base/include/icy/timeout.h:55
Stops the timer without resetting it. expired() will return false after this call.
reset
void reset()Defined in src/base/include/icy/timeout.h:58
Restarts the timer from now, equivalent to calling start().
remaining
const
long remaining() constDefined in src/base/include/icy/timeout.h:63
Returns the number of milliseconds remaining before expiry. Returns 0 if already expired, or the full delay if not running.
Returns
Milliseconds until expiry.
expired
const
bool expired() constDefined in src/base/include/icy/timeout.h:67
Returns true if the timer is running and the delay has fully elapsed.
Returns
true if expired, false if stopped or not yet elapsed.
setDelay
inline
inline void setDelay(long delay)Defined in src/base/include/icy/timeout.h:71
Sets the expiry delay without restarting the timer.
Parameters
delayNew delay in milliseconds.
delay
const inline
inline long delay() constDefined in src/base/include/icy/timeout.h:75
Returns the configured delay in milliseconds.
Returns
Delay in milliseconds.
operator=
Timeout & operator=(const Timeout & src)Defined in src/base/include/icy/timeout.h:79
Copy assignment operator.
Parameters
srcSource Timeout to copy state from.
Protected Attributes
_startAt
std::chrono::steady_clock::time_point _startAtDefined in src/base/include/icy/timeout.h:83
_delay
long _delayDefined in src/base/include/icy/timeout.h:84
_running
bool _running