qb
2.0.0.0
C++17 Actor Framework
|
CRTP base class that adds timeout functionality to derived asynchronous components. More...
#include <io.h>
Public Member Functions | |
with_timeout (ev_tstamp timeout=3) | |
Constructor that initializes the timeout. | |
void | updateTimeout () noexcept |
Updates the last activity timestamp to the current event loop time. | |
void | setTimeout (ev_tstamp timeout) noexcept |
Sets a new timeout value and restarts the timer. | |
auto | getTimeout () const noexcept |
Gets the current configured timeout value. |
Additional Inherited Members | |
Protected Member Functions inherited from qb::io::async::base< with_timeout< _Derived >, event::timer > | |
base () | |
Constructor that registers the event watcher with the current listener. | |
~base () | |
Destructor that unregisters the event watcher. | |
Protected Attributes inherited from qb::io::async::base< with_timeout< _Derived >, event::timer > | |
event::timer & | _async_event |
Reference to the registered libev-based event watcher. |
CRTP base class that adds timeout functionality to derived asynchronous components.
This template class extends qb::io::async::base by incorporating an event::timer. It allows the derived class to set a timeout, after which an on(event::timer&) method in the derived class is triggered if no activity (signaled by updateTimeout()) is detected.
_Derived | The derived class type (CRTP pattern) that will handle the timeout event. |
|
inlineexplicit |
Constructor that initializes the timeout.
timeout | Initial timeout value in seconds. A value of 0.0 or less disables the timeout initially. The timer is started if timeout is greater than 0.0. |
|
inlinenoexcept |
Updates the last activity timestamp to the current event loop time.
This method should be called by the derived class whenever an activity occurs that should reset the timeout countdown (e.g., receiving data, user input). It sets _last_activity to this->_async_event.loop.now().
|
inlinenoexcept |
Sets a new timeout value and restarts the timer.
timeout | New timeout value in seconds. If 0.0 or less, the timer is stopped (disabled). Otherwise, the timer is configured with the new timeout and started. The _last_activity timestamp is also updated to the current event loop time. |
|
inlinenoexcept |
Gets the current configured timeout value.