Add new EventWrapper constructor that takes a Tick value

and schedules the event immediately.

--HG--
extra : convert_revision : a84e729a5ef3632cbe6cff858c453c782707d983
This commit is contained in:
Steve Reinhardt 2007-05-20 21:43:01 -07:00
parent 87adc37e91
commit 05d14cf3e2
6 changed files with 27 additions and 21 deletions

View file

@ -179,10 +179,9 @@ BaseCPU::BaseCPU(Params *p)
if (p->functionTraceStart == 0) {
functionTracingEnabled = true;
} else {
Event *e =
new EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace>(this,
true);
e->schedule(p->functionTraceStart);
new EventWrapper<BaseCPU, &BaseCPU::enableFunctionTrace>(this,
p->functionTraceStart,
true);
}
}
#if FULL_SYSTEM

View file

@ -168,9 +168,7 @@ TimingSimpleCPU::resume()
delete fetchEvent;
}
fetchEvent =
new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, false);
fetchEvent->schedule(nextCycle());
fetchEvent = new FetchEvent(this, nextCycle());
}
changeState(SimObject::Running);
@ -224,9 +222,7 @@ TimingSimpleCPU::activateContext(int thread_num, int delay)
_status = Running;
// kick things off by initiating the fetch of the next instruction
fetchEvent =
new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, false);
fetchEvent->schedule(nextCycle(curTick + cycles(delay)));
fetchEvent = new FetchEvent(this, nextCycle(curTick + cycles(delay)));
}

View file

@ -66,8 +66,6 @@ class TimingSimpleCPU : public BaseSimpleCPU
Event *drainEvent;
Event *fetchEvent;
private:
class CpuPort : public Port
@ -199,7 +197,12 @@ class TimingSimpleCPU : public BaseSimpleCPU
void completeIfetch(PacketPtr );
void completeDataAccess(PacketPtr );
void advanceInst(Fault fault);
private:
typedef EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch> FetchEvent;
FetchEvent *fetchEvent;
void completeDrain();
};

View file

@ -1270,8 +1270,7 @@ NSGigE::cpuIntrPost(Tick when)
if (intrEvent)
intrEvent->squash();
intrEvent = new IntrEvent(this, true);
intrEvent->schedule(intrTick);
intrEvent = new IntrEvent(this, intrTick, true);
}
void
@ -2770,8 +2769,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
Tick intrEventTick;
UNSERIALIZE_SCALAR(intrEventTick);
if (intrEventTick) {
intrEvent = new IntrEvent(this, true);
intrEvent->schedule(intrEventTick);
intrEvent = new IntrEvent(this, intrEventTick, true);
}
}

View file

@ -630,8 +630,7 @@ Base::cpuIntrPost(Tick when)
if (intrEvent)
intrEvent->squash();
intrEvent = new IntrEvent(this, true);
intrEvent->schedule(intrTick);
intrEvent = new IntrEvent(this, intrTick, true);
}
void
@ -1339,8 +1338,7 @@ Base::unserialize(Checkpoint *cp, const std::string &section)
Tick intrEventTick;
UNSERIALIZE_SCALAR(intrEventTick);
if (intrEventTick) {
intrEvent = new IntrEvent(this, true);
intrEvent->schedule(intrEventTick);
intrEvent = new IntrEvent(this, intrEventTick, true);
}
}

View file

@ -293,13 +293,25 @@ class EventWrapper : public Event
T *object;
public:
EventWrapper(T *obj, bool del = false, EventQueue *q = &mainEventQueue,
EventWrapper(T *obj, bool del = false,
EventQueue *q = &mainEventQueue,
Priority p = Default_Pri)
: Event(q, p), object(obj)
{
if (del)
setFlags(AutoDelete);
}
EventWrapper(T *obj, Tick t, bool del = false,
EventQueue *q = &mainEventQueue,
Priority p = Default_Pri)
: Event(q, p), object(obj)
{
if (del)
setFlags(AutoDelete);
schedule(t);
}
void process() { (object->*F)(); }
};