Louvre
v2.13.0-1
C++ library for Wayland compositors
|
Delayed callbacks. More...
Public Types | |
using | Callback = std::function< void(LTimer *)> |
Type definition for the timer's timeout callback function. More... | |
Public Member Functions | |
LTimer (const Callback &onTimeout=nullptr) noexcept | |
Construct a re-usable LTimer instance with the provided timeout callback. More... | |
~LTimer () | |
Destructor for the LTimer class. More... | |
void | setCallback (const Callback &onTimeout) noexcept |
Set the callback function to be executed when the timer expires. More... | |
UInt32 | interval () const noexcept |
Retrieves the interval of the timer in milliseconds. More... | |
bool | running () const noexcept |
Checks if the timer is currently running. More... | |
void | cancel () noexcept |
Cancels the timer without invoking the callback. More... | |
void | stop () noexcept |
Stops the timer invoking the callback immediatly. More... | |
bool | start (UInt32 intervalMs) noexcept |
Starts the timer with the specified interval. More... | |
Public Member Functions inherited from LObject | |
LObject (const LObject &) noexcept | |
Copy constructor. More... | |
LObject & | operator= (const LObject &) noexcept |
Assignment operator (each object has its own individual LWeak reference count). More... | |
void | setUserData (UIntPtr data) const noexcept |
Store an unsigned integer value/pointer. More... | |
UIntPtr | userData () const noexcept |
Retrieves the stored unsigned integer value/pointer. More... | |
Static Public Member Functions | |
static bool | oneShot (UInt32 intervalMs, const Callback &onTimeout) noexcept |
Create a one-shot timer that is automatically started and destroyed on timeout or cancellation. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from LObject | |
LObject () noexcept=default | |
Constructor of the LObject class. More... | |
virtual | ~LObject () noexcept |
Destructor of the LObject class. More... | |
void | notifyDestruction () noexcept |
Notifies the object destruction. More... | |
Delayed callbacks.
This class provides the capability to create and manage timers, allowing you to schedule time intervals in milliseconds and execute a specified callback function when the timer expires. It supports both re-usable timers and one-shot timers that can be automatically destroyed after timeout or cancellation.
Type definition for the timer's timeout callback function.
timer | Pointer to the LTimer instance that triggered the callback. |
Construct a re-usable LTimer instance with the provided timeout callback.
onTimeout | The callback function to be executed when the timer expires. |
~LTimer | ( | ) |
Destructor for the LTimer class.
If the timer is destroyed while it is running, the associated callback function is not invoked.
Create a one-shot timer that is automatically started and destroyed on timeout or cancellation.
intervalMs | The interval for the timer in milliseconds. |
onTimeout | The callback function to be executed when the timer expires. |
true
on successfully, false
otherwise.
|
inlinenoexcept |
Set the callback function to be executed when the timer expires.
onTimeout | The callback function to be executed when the timer expires. |
|
inlinenoexcept |
Retrieves the interval of the timer in milliseconds.
|
inlinenoexcept |
Checks if the timer is currently running.
true
if the timer is running, false
otherwise.
|
noexcept |
Cancels the timer without invoking the callback.
If the timer was created with oneShot() it is destroyed and the onTimeout callback is not called.
|
noexcept |
Stops the timer invoking the callback immediatly.
If the timer was created with oneShot() it is destroyed after the callback is triggered.
|
noexcept |
Starts the timer with the specified interval.
intervalMs | The interval for the timer in milliseconds. |
true
if the timer successfully started, false
otherwise.