class UnwindExceptionReset : public ::sc_core::sc_unwind_exception
{
public:
- const char *what() const throw() override { return "RESET"; }
- bool is_reset() const override { return true; }
+ UnwindExceptionReset() { _isReset = true; }
};
class UnwindExceptionKill : public ::sc_core::sc_unwind_exception
{
public:
- const char *what() const throw() override { return "KILL"; }
- bool is_reset() const override { return false; }
+ UnwindExceptionKill() {}
};
template <typename T>
void
Process::kill(bool inc_kids)
{
- // Update our state.
- _terminated = true;
- _isUnwinding = true;
-
// Propogate the kill to our children no matter what happens to us.
if (inc_kids)
forEachKid([](Process *p) { p->kill(true); });
if (_isUnwinding)
return;
+ // Update our state.
+ _terminated = true;
+ _isUnwinding = true;
+ _suspendedReady = false;
+ _suspended = false;
+ _syncReset = false;
+
// Inject the kill exception into this process.
injectException(killException);
void
Process::reset(bool inc_kids)
{
- // Update our state.
- _isUnwinding = true;
-
// Propogate the reset to our children no matter what happens to us.
if (inc_kids)
forEachKid([](Process *p) { p->reset(true); });
if (_isUnwinding)
return;
+ // Update our state.
+ _isUnwinding = true;
+
// Inject the reset exception into this process.
injectException(resetException);
Process::injectException(ExceptionWrapperBase &exc)
{
excWrapper = &exc;
- // Let this process preempt us.
+ scheduler.runNow(this);
};
void
reset = false;
try {
func->call();
- } catch(::sc_core::sc_unwind_exception exc) {
+ } catch(const ::sc_core::sc_unwind_exception &exc) {
reset = exc.is_reset();
+ _isUnwinding = false;
}
} while (reset);
_terminated = true;
if (_current && _current->needsStart())
_current->run();
}
+ if (_current && _current->excWrapper) {
+ // Make sure this isn't a method process.
+ assert(!_current->needsStart());
+ auto ew = _current->excWrapper;
+ _current->excWrapper = nullptr;
+ ew->throw_it();
+ }
}
void