7#include <unordered_map>
13using TimePoint = std::chrono::steady_clock::time_point;
42 uint64_t
add_timer(
int fd, std::chrono::milliseconds timeout);
84 std::priority_queue<TimerEvent, std::vector<TimerEvent>, std::greater<TimerEvent>>
timers_;
85 std::unordered_map<uint64_t, LiveTimer>
live_;
Manages timers for connection timeouts.
Definition TimerManager.hpp:29
std::priority_queue< TimerEvent, std::vector< TimerEvent >, std::greater< TimerEvent > > timers_
Definition TimerManager.hpp:84
void cancel_timer(uint64_t timer_id)
Cancels a timer by ID.
void compact_if_needed_locked()
int get_next_timeout()
Gets the time remaining until the next timeout.
void drop_cancelled_front_locked()
uint64_t next_timer_id_
Definition TimerManager.hpp:86
std::unordered_map< uint64_t, LiveTimer > live_
Definition TimerManager.hpp:85
void handle_expired_timers(std::function< void(int)> on_timeout)
Processes all expired timers.
std::mutex mutex_
Definition TimerManager.hpp:87
TimerManager()
Constructs a TimerManager.
size_t live_timers()
Timers that have been added and neither fired nor been cancelled.
uint64_t add_timer(int fd, std::chrono::milliseconds timeout)
Adds a timer for a given file descriptor.
Definition Http2Session.hpp:18
std::chrono::steady_clock::time_point TimePoint
Definition TimerManager.hpp:13
Definition TimerManager.hpp:15
bool operator>(const TimerEvent &other) const
Definition TimerManager.hpp:21
TimePoint expiration
Definition TimerManager.hpp:16
uint64_t timer_id
Definition TimerManager.hpp:17
int fd
Definition TimerManager.hpp:18
Definition TimerManager.hpp:71
int fd
Definition TimerManager.hpp:72
TimePoint expiration
Definition TimerManager.hpp:73