34 return lhs.expiry() >
rhs.expiry();
59 slabs_.push_back(std::move(
slab));
69 heap_.reserve(heap_.size() + 1);
70 const auto tmr{allocate(expiry, interval, slot)};
82 while (!heap_.empty()) {
85 if (!heap_.front().pending()) {
89 }
else if (heap_.front().expiry() <= now.
mono_time()) {
106 impl->id = ++max_id_;
107 impl->expiry = expiry;
108 impl->interval = interval;
120 while (!heap_.empty() && !heap_.front().pending()) {
128void TimerQueue::expire(CyclTime now)
135 tmr.slot().invoke(now,
tmr);
136 }
catch (
const std::exception& e) {
137 TOOLBOX_ERROR <<
"exception in i/o timer handler: " << e.what();
144 if (
tmr.interval().count() > 0) {
147 tmr.set_expiry(
max(
tmr.expiry() +
tmr.interval(), now.mono_time() + 1
ns));
150 heap_.push_back(
tmr);
164 if (cancelled_ >
static_cast<int>(heap_.size() >> 1)) {
166 =
remove_if(heap_.begin(), heap_.end(), [](
const auto&
tmr) { return !tmr.pending(); });
167 heap_.erase(
it, heap_.end());
175 auto tmr = heap_.front();
184 if (
impl->ref_count == 1) {
193 }
else if (
impl->ref_count == 0) {