diff options
| -rw-r--r-- | opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt | 22 | ||||
| -rw-r--r-- | opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt index b1d635fd..23d10e8f 100644 --- a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt +++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt @@ -77,14 +77,6 @@ interface Context<S, M> : CoroutineContext.Element { /** * Interrupt an [Entity] process in simulation. * - * @see [Entity.interrupt(Interrupt)] - * @param reason The reason for interrupting the entity. - */ - suspend fun Entity<*, *>.interrupt(reason: String) = interrupt(Interrupt(reason)) - - /** - * Interrupt an [Entity] process in simulation. - * * If an [Entity] process has been suspended, the suspending call will throw an [Interrupt] object as a result of * this call. * Make sure the [Entity] process actually has error handling in place, so it won't take down the whole [Entity] @@ -95,6 +87,14 @@ interface Context<S, M> : CoroutineContext.Element { suspend fun Entity<*, *>.interrupt(interrupt: Interrupt) /** + * Interrupt an [Entity] process in simulation. + * + * @see [Entity.interrupt(Interrupt)] + * @param reason The reason for interrupting the entity. + */ + suspend fun Entity<*, *>.interrupt(reason: String) = interrupt(Interrupt(reason)) + + /** * Suspend the [Context] of the [Entity] in simulation for the given duration of simulation time before resuming * execution and drop all messages that are received during this period. * @@ -139,19 +139,19 @@ interface Context<S, M> : CoroutineContext.Element { * the message. * * @param msg The message to send. + * @param sender The sender of the message. * @param delay The amount of time to wait before the message should be received by the entity. */ - suspend fun Entity<*, *>.send(msg: Any, delay: Duration = 0) + suspend fun Entity<*, *>.send(msg: Any, sender: Entity<*, *>, delay: Duration = 0) /** * Send the given message to the specified entity, without providing any guarantees about the actual delivery of * the message. * * @param msg The message to send. - * @param sender The sender of the message. * @param delay The amount of time to wait before the message should be received by the entity. */ - suspend fun Entity<*, *>.send(msg: Any, sender: Entity<*, *>, delay: Duration = 0) + suspend fun Entity<*, *>.send(msg: Any, delay: Duration = 0) = send(msg, self, delay) /** * This key provides users access to an untyped process context in case the coroutine runs inside a simulation. diff --git a/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt b/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt index 4d94bf9e..532a033a 100644 --- a/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt +++ b/opendc-kernel-omega/src/main/kotlin/com/atlarge/opendc/omega/OmegaSimulation.kt @@ -327,8 +327,6 @@ internal class OmegaSimulation<M>(bootstrap: Bootstrap<M>) : Simulation<M>, Boot } } - override suspend fun Entity<*, *>.send(msg: Any, delay: Duration) = send(msg, process, delay) - override suspend fun Entity<*, *>.send(msg: Any, sender: Entity<*, *>, delay: Duration) = schedule(prepare(msg, this, sender, delay)) |
