From 7c904d9d3faff80d724c8ab3e6f1d3815545e2f5 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 4 Aug 2015 10:31:37 +0100 Subject: [PATCH] sim: Initialize Drainable::_drainState to the system's state It is sometimes desirable to be able to instantiate Drainable objects when the simulator isn't in the Running state. Currently, we always initialize Drainable objects to the Running state. However, this confuses many of the sanity checks in the base class since objects aren't expected to be in the Running state if the system is in the Draining or Drained state. Instead of always initializing the state variable in Drainable to DrainState::Running, initialize it to the state the DrainManager is in. Note: This means an object can be created in the Draining/Drained state without first calling drain(). --- src/sim/drain.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim/drain.cc b/src/sim/drain.cc index 8549da261..c60734876 100644 --- a/src/sim/drain.cc +++ b/src/sim/drain.cc @@ -150,7 +150,7 @@ DrainManager::drainableCount() const Drainable::Drainable() : _drainManager(DrainManager::instance()), - _drainState(DrainState::Running) + _drainState(_drainManager.state()) { _drainManager.registerDrainable(this); } -- 2.30.2