77c77,87
< Event *next;
---
> // The event queue is now a linked list of linked lists. The
> // 'nextBin' pointer is to find the bin, where a bin is defined as
> // when+priority. All events in the same bin will be stored in a
> // second circularly linked list maintained by the 'nextInBin'
> // pointer. The list will be accessed in FIFO order. The end
> // result is that the insert/removal in 'nextBin' is
> // linear/constant, and the lookup/removal in 'nextInBin' is
> // constant/constant. Hopefully this is a significant improvement
> // over the current fully linear insertion.
> Event *nextBin;
> Event *nextInBin;
78a89,91
> friend void insertBefore(Event *event, Event *curr);
> friend Event *removeItem(Event *event, Event *last);
>
101a115
>
102a117,126
> void
> setWhen(Tick when)
> {
> _when = when;
> #ifdef DEBUG_EVENTQ
> whenScheduled = curTick;
> #endif
> }
>
> protected:
184c208
< : next(NULL), _queue(q), _priority(p), _flags(None)
---
> : nextBin(NULL), nextInBin(NULL), _queue(q), _priority(p), _flags(None)
346c370
< void schedule(Event *ev);
---
> void schedule(Event *ev, Tick when);
348c372
< void reschedule(Event *ev);
---
> void reschedule(Event *ev, Tick when);
381a406,407
> bool debugVerify() const;
>
399c425
< Event::schedule(Tick t)
---
> Event::schedule(Tick when)
401,409c427
< assert(!scheduled());
< assert(t >= curTick);
<
< setFlags(Scheduled);
< #ifdef DEBUG_EVENTQ
< whenScheduled = curTick;
< #endif
< _when = t;
< _queue->schedule(this);
---
> _queue->schedule(this, when);
415,418d432
< assert(scheduled());
<
< clearFlags(Squashed);
< clearFlags(Scheduled);
423c437
< Event::reschedule(Tick t, bool always)
---
> Event::reschedule(Tick when, bool always)
425,432d438
< assert(scheduled() || always);
< assert(t >= curTick);
<
< #ifdef DEBUG_EVENTQ
< whenScheduled = curTick;
< #endif
< _when = t;
<
434,435c440
< clearFlags(Squashed);
< _queue->reschedule(this);
---
> _queue->reschedule(this, when);
437,438c442,443
< setFlags(Scheduled);
< _queue->schedule(this);
---
> assert(always);
> _queue->schedule(this, when);
441a447,485
> inline bool
> operator<(const Event &l, const Event &r)
> {
> return l.when() < r.when() ||
> (l.when() == r.when() && l.priority() < r.priority());
> }
>
> inline bool
> operator>(const Event &l, const Event &r)
> {
> return l.when() > r.when() ||
> (l.when() == r.when() && l.priority() > r.priority());
> }
>
> inline bool
> operator<=(const Event &l, const Event &r)
> {
> return l.when() < r.when() ||
> (l.when() == r.when() && l.priority() <= r.priority());
> }
> inline bool
> operator>=(const Event &l, const Event &r)
> {
> return l.when() > r.when() ||
> (l.when() == r.when() && l.priority() >= r.priority());
> }
>
> inline bool
> operator==(const Event &l, const Event &r)
> {
> return l.when() == r.when() && l.priority() == r.priority();
> }
>
> inline bool
> operator!=(const Event &l, const Event &r)
> {
> return l.when() != r.when() || l.priority() != r.priority();
> }
>
443c487
< EventQueue::schedule(Event *event)
---
> EventQueue::schedule(Event *event, Tick when)
444a489,492
> assert(when >= curTick);
> assert(!event->scheduled());
>
> event->setWhen(when);
445a494,495
> event->setFlags(Event::Scheduled);
>
452a503,504
> assert(event->scheduled());
>
454,455d505
< if (DTRACE(Event))
< event->trace("descheduled");
456a507,509
> event->clearFlags(Event::Squashed);
> event->clearFlags(Event::Scheduled);
>
458a512,514
>
> if (DTRACE(Event))
> event->trace("descheduled");
462c518
< EventQueue::reschedule(Event *event)
---
> EventQueue::reschedule(Event *event, Tick when)
463a520,522
> assert(when >= curTick);
> assert(event->scheduled());
>
464a524
> event->setWhen(when);
465a526,527
> event->clearFlags(Event::Squashed);
>