![]() |
Louvre v2.18.1-1
C++ library for Wayland compositors
|
Delayed callbacks. More...
#include <LTimer.h>
Inheritance diagram for LTimer:Public Types | |
| using | Callback = std::function< void(LTimer *)> |
| Type definition for the timer's timeout callback function. | |
Public Member Functions | |
| LTimer (const Callback &onTimeout=nullptr) noexcept | |
| Construct a re-usable LTimer instance with the provided timeout callback. | |
| ~LTimer () | |
| Destructor for the LTimer class. | |
| void | setCallback (const Callback &onTimeout) noexcept |
| Set the callback function to be executed when the timer expires. | |
| UInt32 | interval () const noexcept |
| Retrieves the interval of the timer in milliseconds. | |
| bool | running () const noexcept |
| Checks if the timer is currently running. | |
| void | cancel () noexcept |
| Cancels the timer without invoking the callback. | |
| void | stop () noexcept |
| Stops the timer invoking the callback immediatly. | |
| bool | start (UInt32 intervalMs) noexcept |
| Starts the timer with the specified interval. | |
Public Member Functions inherited from LObject | |
| LObject (const LObject &) noexcept | |
| Copy constructor. | |
| LObject & | operator= (const LObject &) noexcept |
| Assignment operator (each object has its own individual LWeak reference count). | |
| void | setUserData (UIntPtr data) const noexcept |
| Store an unsigned integer value/pointer. | |
| UIntPtr | userData () const noexcept |
| Retrieves the stored unsigned integer value/pointer. | |
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. | |
Additional Inherited Members | |
Protected Member Functions inherited from LObject | |
| LObject () noexcept=default | |
| Constructor of the LObject class. | |
| virtual | ~LObject () noexcept |
| Destructor of the LObject class. | |
| void | notifyDestruction () noexcept |
| Notifies the object destruction. | |
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.