Manages timers for connection timeouts.
More...
#include <TimerManager.hpp>
Manages timers for connection timeouts.
◆ TimerManager()
| server::TimerManager::TimerManager |
( |
| ) |
|
|
default |
◆ add_timer()
| uint64_t server::TimerManager::add_timer |
( |
int |
fd, |
|
|
std::chrono::milliseconds |
timeout |
|
) |
| |
Adds a timer for a given file descriptor.
- Parameters
-
| fd | The file descriptor. |
| timeout | The timeout duration. |
- Returns
- The timer ID.
◆ cancel_timer()
| void server::TimerManager::cancel_timer |
( |
uint64_t |
timer_id | ) |
|
Cancels a timer by ID.
- Parameters
-
◆ get_next_timeout()
| int server::TimerManager::get_next_timeout |
( |
| ) |
|
Gets the time remaining until the next timeout.
- Returns
- Milliseconds until the next timeout, or -1 if none.
◆ handle_expired_timers()
| void server::TimerManager::handle_expired_timers |
( |
std::function< void(int)> |
on_timeout | ) |
|
Processes all expired timers.
- Parameters
-
| on_timeout | Callback invoked for each expired timer with its file descriptor. |
The documentation for this class was generated from the following files: