diff options
Diffstat (limited to 'src/python/swig/event.i')
-rw-r--r-- | src/python/swig/event.i | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/python/swig/event.i b/src/python/swig/event.i index 10d75d2de..b40e59a4b 100644 --- a/src/python/swig/event.i +++ b/src/python/swig/event.i @@ -41,6 +41,35 @@ #pragma SWIG nowarn=350,351 +%extend EventQueue { + void + schedule(Event *event, Tick when) + { + // Any python event that are scheduled must have their + // internal object's refcount incremented so that the object + // sticks around while it is in the event queue. + PythonEvent *pyevent = dynamic_cast<PythonEvent *>(event); + if (pyevent) + pyevent->incref(); + $self->schedule(event, when); + } + + void + deschedule(Event *event) + { + $self->deschedule(event); + + // Now that we're removing the python object from the event + // queue, we need to decrement its reference count. + PythonEvent *pyevent = dynamic_cast<PythonEvent *>(event); + if (pyevent) + pyevent->decref(); + } +} + +%ignore EventQueue::schedule; +%ignore EventQueue::deschedule; + %import "base/fast_alloc.hh" %import "sim/serialize.hh" |