A header-only C++17 priority queue based on Clock::time_point
s
Classes defined in header lyn/timer_queue.hpp
.
template<
class R, class... Args
class Clock = std::chrono::steady_clock,
class TimePoint = std::chrono::time_point<Clock>,
bool SetDelayEnabled = true
> class timer_queue; /* undefined */
template<class R, class... Args, class Clock, class TimePoint, bool SetDelayEnabled>
class timer_queue<R(Args...), Clock, TimePoint>;
A timer queue provides constant time lookup of the first event to timeout, at the expense of logarithmic insertion and extraction.
Parameter | Description |
---|---|
R | The return type of events to store in the queue. |
Args... | The arguments to pass to events stored in the queue. |
Clock | The clock type used to keep time. std::chrono::steady_clock by default. |
TimePoint | std::chrono::time_point<Clock> |
SetDelayEnabled | If true , enables set_delay_until and related functionality. |
Member types | Definitions |
---|---|
event_type |
The type you extract in the event loop |
clock_type |
Clock |
duration |
Clock::duration |
time_point |
TimePoint |
event_container |
unspecified - Has a member function bool pop(event_type& ev) - see wait_pop_all |
schedule_at_type |
std::pair<time_point, event_type> |
schedule_in_type |
std::pair<duration, event_type> |
template<class QT>
class timer_queue_registrator;
A timer_queue_registrator
is a RAII wrapper used to register a user (usually a thread) to a timer_queue
and to unregister from the timer_queue
when the timer_queue_registrator
is destroyed.
Parameter | Description |
---|---|
QT | The specific timer_queue type |
Member types | Definitions |
---|---|
timer_queue |
QT |
event_type |
timer_queue::event_type |
event_container |
timer_queue::event_container |
Observers |
|
---|---|
queue_type& queue() |
Returns a reference to the timer_queue supplied at construction |
Compiler | OS | CPU | events / second |
---|---|---|---|
g++12 | Fedora 37 | Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz | 700,000 - 1,400,000 |
clang++15 | Fedora 37 | Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz | 1,200,000 - 1,500,000 |
g++12 | Ubuntu 22.04 WSL Windows 11 |
Intel(R) Core(TM) i9-7920X CPU @ 2.90GHz | 1,350,000 - 1,600,000 |
clang++15 | Ubuntu 22.04 WSL Windows 11 |
Intel(R) Core(TM) i9-7920X CPU @ 2.90GHz | 1,400,000 - 1,500,000 |
VS 17.5.0 MSVC 19.35 |
Windows 11 | Intel(R) Core(TM) i9-7920X CPU @ 2.90GHz | 2,300,000 - 2,700,000 |