summaryrefslogtreecommitdiff
path: root/src/python/swig/pyevent.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-04-06 10:19:36 -0700
committerGabe Black <gblack@eecs.umich.edu>2009-04-06 10:19:36 -0700
commitd080581db1f9ee4e1e6d07d2b01c13c67908a391 (patch)
treecc484b289fa5a30c4631f9faa1d8b456bffeebfc /src/python/swig/pyevent.cc
parent7a7c4c5fca83a8d47c7e71c9c080a882ebe204a9 (diff)
parent639cb0a42d953ee32bc7e96b0cdfa96cd40e9fc1 (diff)
downloadgem5-d080581db1f9ee4e1e6d07d2b01c13c67908a391.tar.xz
Merge ARM into the head. ARM will compile but may not actually work.
Diffstat (limited to 'src/python/swig/pyevent.cc')
-rw-r--r--src/python/swig/pyevent.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/python/swig/pyevent.cc b/src/python/swig/pyevent.cc
index 7f23b8874..0695ed2d3 100644
--- a/src/python/swig/pyevent.cc
+++ b/src/python/swig/pyevent.cc
@@ -33,21 +33,15 @@
#include "python/swig/pyevent.hh"
#include "sim/async.hh"
-PythonEvent::PythonEvent(PyObject *obj, Tick when, Priority priority)
- : Event(&mainEventQueue, priority), object(obj)
+PythonEvent::PythonEvent(PyObject *obj, Priority priority)
+ : Event(priority), object(obj)
{
if (object == NULL)
panic("Passed in invalid object");
-
- Py_INCREF(object);
-
- setFlags(AutoDelete);
- schedule(when);
}
PythonEvent::~PythonEvent()
{
- Py_DECREF(object);
}
void
@@ -66,4 +60,27 @@ PythonEvent::process()
async_event = true;
async_exception = true;
}
+
+ // Since the object has been removed from the event queue, its
+ // reference count must be decremented.
+ Py_DECREF(object);
+}
+
+CountedDrainEvent *
+createCountedDrain()
+{
+ return new CountedDrainEvent();
+}
+
+void
+cleanupCountedDrain(Event *counted_drain)
+{
+ CountedDrainEvent *event =
+ dynamic_cast<CountedDrainEvent *>(counted_drain);
+ if (event == NULL) {
+ fatal("Called cleanupCountedDrain() on an event that was not "
+ "a CountedDrainEvent.");
+ }
+ assert(event->getCount() == 0);
+ delete event;
}