- Add exception checking to ConcreteSimulation::jump_to()
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1054 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
45a72aa0a8
commit
e4d359304c
|
@ -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 \
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<SimulationObserver*> RegisteredObservers;
|
||||
|
|
|
@ -88,3 +88,9 @@ Simulation::set_notify_enabled(bool enabled)
|
|||
|
||||
return old_value;
|
||||
}
|
||||
|
||||
bool
|
||||
Simulation::is_notify_enabled() const
|
||||
{
|
||||
return _notify;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue