Deleted Added
sdiff udiff text old ( 12993:977fa1dfe9b3 ) new ( 12995:3421144dd03e )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 94 unchanged lines hidden (view full) ---

103 for (auto e: list->events)
104 Event::getFromScEvent(e)->delSensitivity(this);
105}
106
107
108class UnwindExceptionReset : public ::sc_core::sc_unwind_exception
109{
110 public:
111 const char *what() const throw() override { return "RESET"; }
112 bool is_reset() const override { return true; }
113};
114
115class UnwindExceptionKill : public ::sc_core::sc_unwind_exception
116{
117 public:
118 const char *what() const throw() override { return "KILL"; }
119 bool is_reset() const override { return false; }
120};
121
122template <typename T>
123struct BuiltinExceptionWrapper : public ExceptionWrapperBase
124{
125 public:
126 T t;
127 void throw_it() override { throw t; }

--- 61 unchanged lines hidden (view full) ---

189 forEachKid([](Process *p) { p->enable(true); });
190
191 _disabled = false;
192}
193
194void
195Process::kill(bool inc_kids)
196{
197 // Update our state.
198 _terminated = true;
199 _isUnwinding = true;
200
201 // Propogate the kill to our children no matter what happens to us.
202 if (inc_kids)
203 forEachKid([](Process *p) { p->kill(true); });
204
205 // If we're in the middle of unwinding, ignore the kill request.
206 if (_isUnwinding)
207 return;
208
209 // Inject the kill exception into this process.
210 injectException(killException);
211
212 _terminatedEvent.notify();
213}
214
215void
216Process::reset(bool inc_kids)
217{
218 // Update our state.
219 _isUnwinding = true;
220
221 // Propogate the reset to our children no matter what happens to us.
222 if (inc_kids)
223 forEachKid([](Process *p) { p->reset(true); });
224
225 // If we're in the middle of unwinding, ignore the reset request.
226 if (_isUnwinding)
227 return;
228
229 // Inject the reset exception into this process.
230 injectException(resetException);
231
232 _resetEvent.notify();
233}
234
235void
236Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
237{
238 if (inc_kids)
239 forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
240}
241
242void
243Process::injectException(ExceptionWrapperBase &exc)
244{
245 excWrapper = &exc;
246 // Let this process preempt us.
247};
248
249void
250Process::syncResetOn(bool inc_kids)
251{
252 if (inc_kids)
253 forEachKid([](Process *p) { p->syncResetOn(true); });
254

--- 29 unchanged lines hidden (view full) ---

284void
285Process::run()
286{
287 bool reset;
288 do {
289 reset = false;
290 try {
291 func->call();
292 } catch(::sc_core::sc_unwind_exception exc) {
293 reset = exc.is_reset();
294 }
295 } while (reset);
296 _terminated = true;
297}
298
299void
300Process::addStatic(PendingSensitivity *s)
301{

--- 50 unchanged lines hidden ---