diff options
Diffstat (limited to 'src/python/m5/event.py')
-rw-r--r-- | src/python/m5/event.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/python/m5/event.py b/src/python/m5/event.py index 2d6497464..35095599d 100644 --- a/src/python/m5/event.py +++ b/src/python/m5/event.py @@ -26,17 +26,36 @@ # # Authors: Nathan Binkert -from internal.event import create -from internal.event import SimLoopExitEvent as SimExit +import m5 +import internal.event + +from internal.event import PythonEvent, SimLoopExitEvent as SimExit + +mainq = internal.event.cvar.mainEventQueue + +def create(obj, priority=None): + if priority is None: + priority = Event.Default_Pri + return PythonEvent(obj, priority) -class ProgressEvent(object): - def __init__(self, period): - self.period = int(period) - self.schedule() - def schedule(self): - create(self, m5.curTick() + self.period) +# As a reminder, priorities found in sim/eventq.hh are stuck into the +# Event class by swig +class Event(PythonEvent): + def __init__(self, priority=None): + if priority is None: + priority = Event.Default_Pri + super(Event, self).__init__(self, priority) + +class ProgressEvent(Event): + def __init__(self, eventq, period): + super(ProgressEvent, self).__init__() + self.period = int(period) + self.eventq = eventq + self.eventq.schedule(self, m5.curTick() + self.period) def __call__(self): print "Progress! Time now %fs" % (m5.curTick()/1e12) - self.schedule() + self.eventq.schedule(self, m5.curTick() + self.period) + +__all__ = [ 'create', 'Event', 'ProgressEvent', 'SimExit', 'mainq' ] |