diff options
| author | Fabian Mastenbroek <fabianishere@outlook.com> | 2018-07-19 15:52:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-19 15:52:04 +0200 |
| commit | d37a139b357ded9ba048c10ccad320a0d8412f0b (patch) | |
| tree | 4ae1d87574e30862303947f9f78152f5524ef75f /opendc-core/src/main | |
| parent | 28974348022dc7c339359ffb099ec55d2c76e457 (diff) | |
refactor: Improve exception handling in processes (#29)
This change will improve exception handling of processes.
At the moment, when a process throws an uncaught exception, the kernel will catch and log the exception, stop the offending process and then continue. This approach however might cause the user to overlook possible exceptions in processes and does not give any ability to the user for handling these exception.
This change modifies the kernel implementation and specification such that the `step()` method (and consequently `run()`) must propagate uncaught exceptions that occur in processes. This allows the caller to control the way exceptions are handled.
Diffstat (limited to 'opendc-core/src/main')
| -rw-r--r-- | opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt index 0954868a..14ce5a1a 100644 --- a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt +++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Simulation.kt @@ -63,12 +63,16 @@ interface Simulation<M> { /** * Step through one cycle in the simulation. This method will process all events in a single tick, update the * internal clock and then return the control to the user. + * + * This method will throw if a process running during the cycle throws an exception. */ fun step() /** * Run a simulation over the specified model. * This method will step through multiple cycles in the simulation until no more message exist in the queue. + * + * This method will throw if a process running during a cycle throws an exception. */ fun run() @@ -76,6 +80,8 @@ interface Simulation<M> { * Run a simulation over the specified model, stepping through cycles until the specified clock tick has * occurred. The control is then handed back to the user. * + * This method will throw if a process running during a cycle throws an exception. + * * @param until The point in simulation time at which the simulation should be paused and the control is handed * back to the user. */ |
