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.
This commit is contained in:
parent
ba79155d9d
commit
84f0a1bd91
9 changed files with 23 additions and 41 deletions
|
@ -71,9 +71,8 @@ using namespace std;
|
|||
template <class Impl>
|
||||
DefaultCommit<Impl>::TrapEvent::TrapEvent(DefaultCommit<Impl> *_commit,
|
||||
ThreadID _tid)
|
||||
: Event(CPU_Tick_Pri), commit(_commit), tid(_tid)
|
||||
: Event(CPU_Tick_Pri, AutoDelete), commit(_commit), tid(_tid)
|
||||
{
|
||||
this->setFlags(AutoDelete);
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
|
|
|
@ -56,10 +56,9 @@ using namespace std;
|
|||
template <class Impl>
|
||||
InstructionQueue<Impl>::FUCompletion::FUCompletion(DynInstPtr &_inst,
|
||||
int fu_idx, InstructionQueue<Impl> *iq_ptr)
|
||||
: Event(Stat_Event_Pri), inst(_inst), fuIdx(fu_idx), iqPtr(iq_ptr),
|
||||
freeFU(false)
|
||||
: Event(Stat_Event_Pri, AutoDelete),
|
||||
inst(_inst), fuIdx(fu_idx), iqPtr(iq_ptr), freeFU(false)
|
||||
{
|
||||
this->setFlags(Event::AutoDelete);
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
|
|
|
@ -60,9 +60,9 @@
|
|||
template<class Impl>
|
||||
LSQUnit<Impl>::WritebackEvent::WritebackEvent(DynInstPtr &_inst, PacketPtr _pkt,
|
||||
LSQUnit *lsq_ptr)
|
||||
: inst(_inst), pkt(_pkt), lsqPtr(lsq_ptr)
|
||||
: Event(Default_Pri, AutoDelete),
|
||||
inst(_inst), pkt(_pkt), lsqPtr(lsq_ptr)
|
||||
{
|
||||
this->setFlags(Event::AutoDelete);
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
|
|
|
@ -228,17 +228,13 @@ EtherLink::Link::unserialize(const string &base, Checkpoint *cp,
|
|||
}
|
||||
|
||||
LinkDelayEvent::LinkDelayEvent()
|
||||
: link(NULL)
|
||||
: Event(Default_Pri, AutoSerialize | AutoDelete), link(NULL)
|
||||
{
|
||||
setFlags(AutoSerialize);
|
||||
setFlags(AutoDelete);
|
||||
}
|
||||
|
||||
LinkDelayEvent::LinkDelayEvent(EtherLink::Link *l, EthPacketPtr p)
|
||||
: link(l), packet(p)
|
||||
: Event(Default_Pri, AutoSerialize | AutoDelete), link(l), packet(p)
|
||||
{
|
||||
setFlags(AutoSerialize);
|
||||
setFlags(AutoDelete);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -39,9 +39,9 @@ class RubyEventQueueNode : public Event
|
|||
{
|
||||
public:
|
||||
RubyEventQueueNode(Consumer* _consumer, RubyEventQueue* _eventq)
|
||||
: m_consumer_ptr(_consumer), m_eventq_ptr(_eventq)
|
||||
: Event(Default_Pri, AutoDelete),
|
||||
m_consumer_ptr(_consumer), m_eventq_ptr(_eventq)
|
||||
{
|
||||
setFlags(AutoDelete);
|
||||
}
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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"; }
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue