From e4d359304c4472f682663b2c2ab5ae9b0aa0dd2c Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 7 Sep 2006 21:26:41 +0000 Subject: [PATCH] - Add exception checking to ConcreteSimulation::jump_to() git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1054 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 2 +- src/backend/concrete_simulation.cc | 21 +++++++++++---------- src/backend/sgpemv2/simulation.hh | 1 + src/backend/simulation.cc | 6 ++++++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 155d47a..f3f3947 100644 --- a/Makefile.am +++ b/Makefile.am @@ -247,7 +247,7 @@ pkginclude_HEADERS += \ src/backend/sgpemv2/process.hh \ src/backend/sgpemv2/schedulable.hh \ src/backend/sgpemv2/schedulable_statistics.hh \ - src/backend/sgpemv2/scheduler.hh \ + src/backend/sgpemv2/scheduler.hh \ src/backend/sgpemv2/serialize_visitor.hh \ src/backend/sgpemv2/serializer.hh \ src/backend/sgpemv2/serializer_error.hh \ diff --git a/src/backend/concrete_simulation.cc b/src/backend/concrete_simulation.cc index 4285682..23ca660 100644 --- a/src/backend/concrete_simulation.cc +++ b/src/backend/concrete_simulation.cc @@ -72,12 +72,11 @@ ConcreteSimulation::jump_to(History::position p) throw(UserInterruptException, N } // Disable momentarily updates for registered observers on - // sgpem::Simulation too. - set_notify_enabled(false); - pause(); + // sgpem::Simulation and sgpem::History. + bool his_enabled = _history.set_notify_enabled(false); + bool sim_enabled = set_notify_enabled(false); - // Disable updates to registered observers - _history.set_notify_enabled(false); + pause(); bool yet_to_finish = true; History::position increment = 0; @@ -88,10 +87,12 @@ ConcreteSimulation::jump_to(History::position p) throw(UserInterruptException, N yet_to_finish = step(); increment++; } - catch(...) + catch(const CPUPolicyException&) { - // FIXME: manage exceptions! Lookout that notifications - // have to be re-enabled. + // Lookout that notifications have to be re-enabled. + _history.set_notify_enabled(his_enabled); + set_notify_enabled(sim_enabled); + throw; } } get_history().set_front(std::min(p, _history.get_size())); @@ -100,11 +101,11 @@ ConcreteSimulation::jump_to(History::position p) throw(UserInterruptException, N // Reenables updates to registered observers. // Calls _history.notify_change() on reactivation. - _history.set_notify_enabled(true); + _history.set_notify_enabled(his_enabled); // Do the same for notifications on the state // of Simulation - set_notify_enabled(true); + set_notify_enabled(sim_enabled); } diff --git a/src/backend/sgpemv2/simulation.hh b/src/backend/sgpemv2/simulation.hh index 9875f66..9ad1205 100644 --- a/src/backend/sgpemv2/simulation.hh +++ b/src/backend/sgpemv2/simulation.hh @@ -179,6 +179,7 @@ namespace sgpem * \return The old value */ virtual bool set_notify_enabled(bool enabled = true); + bool is_notify_enabled() const; protected: typedef std::vector RegisteredObservers; diff --git a/src/backend/simulation.cc b/src/backend/simulation.cc index 8b420ca..43b6730 100644 --- a/src/backend/simulation.cc +++ b/src/backend/simulation.cc @@ -88,3 +88,9 @@ Simulation::set_notify_enabled(bool enabled) return old_value; } + +bool +Simulation::is_notify_enabled() const +{ + return _notify; +}