From 84f0a1bd91b8af5517711fba00533daddb2359e1 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 22 Sep 2011 18:59:55 -0700 Subject: event: minor cleanup Initialize flags via the Event constructor instead of calling setFlags() in the body of the derived class's constructor. I forget exactly why, but this made life easier when implementing multi-queue support. Also rename Event::getFlags() to isFlagSet() to better match common usage, and get rid of some unused Event methods. --- src/sim/debug.cc | 3 +-- src/sim/eventq.hh | 26 ++++++++------------------ src/sim/sim_events.cc | 7 +++---- src/sim/stat_control.cc | 4 ++-- 4 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src/sim') diff --git a/src/sim/debug.cc b/src/sim/debug.cc index bd7924117..fadd89ae1 100644 --- a/src/sim/debug.cc +++ b/src/sim/debug.cc @@ -57,9 +57,8 @@ struct DebugBreakEvent : public Event // constructor: schedule at specified time // DebugBreakEvent::DebugBreakEvent() - : Event(Debug_Break_Pri) + : Event(Debug_Break_Pri, AutoDelete) { - setFlags(AutoDelete); } // diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index fcfa119c4..1509d05a5 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -149,20 +149,13 @@ class Event : public Serializable, public FastAlloc return flags & PublicRead; } - Flags - getFlags(Flags _flags) const + bool + isFlagSet(Flags _flags) const { assert(_flags.noneSet(~PublicRead)); return flags.isSet(_flags); } - Flags - allFlags(Flags _flags) const - { - assert(_flags.noneSet(~PublicRead)); - return flags.allSet(_flags); - } - /// Accessor for flags. void setFlags(Flags _flags) @@ -247,9 +240,11 @@ class Event : public Serializable, public FastAlloc * Event constructor * @param queue that the event gets scheduled on */ - Event(Priority p = Default_Pri) - : nextBin(NULL), nextInBin(NULL), _priority(p), flags(Initialized) + Event(Priority p = Default_Pri, Flags f = 0) + : nextBin(NULL), nextInBin(NULL), _priority(p), + flags(Initialized | f) { + assert(f.noneSet(~PublicWrite)); #ifndef NDEBUG instance = ++instanceCounter; queue = NULL; @@ -406,16 +401,11 @@ class EventQueue : public Serializable } } - // default: process all events up to 'now' (curTick()) - void serviceEvents() { serviceEvents(curTick()); } - // return true if no events are queued bool empty() const { return head == NULL; } void dump() const; - Tick nextEventTime() { return empty() ? curTick() : head->when(); } - bool debugVerify() const; #ifndef SWIG @@ -559,8 +549,8 @@ DelayFunction(EventQueue *eventq, Tick when, T *object) public: DelayEvent(T *o) - : object(o) - { this->setFlags(AutoDelete); } + : Event(Default_Pri, AutoDelete), object(o) + { } void process() { (object->*F)(); } const char *description() const { return "delay"; } }; diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc index aac844429..725e7da9d 100644 --- a/src/sim/sim_events.cc +++ b/src/sim/sim_events.cc @@ -40,9 +40,8 @@ using namespace std; SimLoopExitEvent::SimLoopExitEvent(const std::string &_cause, int c, Tick r) - : Event(Sim_Exit_Pri), cause(_cause), code(c), repeat(r) + : Event(Sim_Exit_Pri, IsExitEvent), cause(_cause), code(c), repeat(r) { - setFlags(IsExitEvent); } @@ -55,7 +54,7 @@ SimLoopExitEvent::process() // if this got scheduled on a different queue (e.g. the committed // instruction queue) then make a corresponding event on the main // queue. - if (!getFlags(IsMainQueue)) { + if (!isFlagSet(IsMainQueue)) { exitSimLoop(cause, code); delete this; } @@ -65,7 +64,7 @@ SimLoopExitEvent::process() // but if you are doing this on intervals, don't forget to make another if (repeat) { - assert(getFlags(IsMainQueue)); + assert(isFlagSet(IsMainQueue)); mainEventQueue.schedule(this, curTick() + repeat); } } diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc index 80aec224e..7cf77174f 100644 --- a/src/sim/stat_control.cc +++ b/src/sim/stat_control.cc @@ -175,9 +175,9 @@ class StatEvent : public Event public: StatEvent(bool _dump, bool _reset, Tick _repeat) - : Event(Stat_Event_Pri), dump(_dump), reset(_reset), repeat(_repeat) + : Event(Stat_Event_Pri, AutoDelete), + dump(_dump), reset(_reset), repeat(_repeat) { - setFlags(AutoDelete); } virtual void -- cgit v1.2.3