sim: Move the draining interface into a separate base class

This patch moves the draining interface from SimObject to a separate
class that can be used by any object needing draining. However,
objects not visible to the Python code (i.e., objects not deriving
from SimObject) still depend on their parents informing them when to
drain. This patch also gets rid of the CountedDrainEvent (which isn't
really an event) and replaces it with a DrainManager.
This commit is contained in:
Andreas Sandberg
2012-11-02 11:32:01 -05:00
parent eb703a4b4e
commit b81a977e6a
64 changed files with 691 additions and 444 deletions

View File

@@ -169,19 +169,19 @@ def doDrain(root):
# be drained.
def drain(root):
all_drained = False
drain_event = internal.event.createCountedDrain()
unready_objs = sum(obj.drain(drain_event) for obj in root.descendants())
dm = internal.drain.createDrainManager()
unready_objs = sum(obj.drain(dm) for obj in root.descendants())
# If we've got some objects that can't drain immediately, then simulate
if unready_objs > 0:
drain_event.setCount(unready_objs)
dm.setCount(unready_objs)
simulate()
else:
all_drained = True
internal.event.cleanupCountedDrain(drain_event)
internal.drain.cleanupDrainManager(dm)
return all_drained
def resume(root):
for obj in root.descendants(): obj.resume()
for obj in root.descendants(): obj.drainResume()
def checkpoint(dir):
root = objects.Root.getInstance()