Commit 0f99a803 authored by Juho Snellman's avatar Juho Snellman

Remove the internal schedule_absolute method

- The logic there was buggy on anything but the downmost wheel, not taking
  into account the bitshifting of the tick count. Do the simple thing
  instead.
- Replace the downward hierarchy link with one all the way to the bottom;
  we now never need to go down just a single layer.
parent aa6d82ce
...@@ -134,7 +134,13 @@ public: ...@@ -134,7 +134,13 @@ public:
auto event = slot->pop_event(); auto event = slot->pop_event();
if (down_) { if (down_) {
assert((down_->now_ & MASK) == 0); assert((down_->now_ & MASK) == 0);
down_->schedule_absolute(event, event->scheduled_at()); Tick now = down_->now();
if (now >= event->scheduled_at()) {
event->execute();
} else {
down_->schedule(event,
event->scheduled_at() - now);
}
} else { } else {
event->execute(); event->execute();
} }
...@@ -174,25 +180,8 @@ private: ...@@ -174,25 +180,8 @@ private:
: now_(0), : now_(0),
down_(down) { down_(down) {
if (offset + WIDTH_BITS < 64) { if (offset + WIDTH_BITS < 64) {
up_ = new TimerWheel(offset + WIDTH_BITS, this); up_ = new TimerWheel(offset + WIDTH_BITS, down);
}
}
void schedule_absolute(TimerEventInterface* event, Tick absolute) {
Tick delta;
delta = absolute - now_;
assert(absolute >= now_);
assert(delta < NUM_SLOTS);
if (delta == 0) {
if (!down_) {
event->execute();
} else {
down_->schedule_absolute(event, absolute);
} }
return;
}
schedule(event, delta);
} }
Tick now_; Tick now_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment