From b84a995a05fecb9ef90c9184959f285f324e7411 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 16 Feb 2018 14:39:53 +0100 Subject: refactor(#18): Provide access to latest sender This change adds a `sender` property to the `Context` interface to provide processes access to the sender of the latest received message. Please note that methods like `hold()` and `interrupt()` may change the value of this property. --- .../src/main/kotlin/com/atlarge/opendc/simulator/Context.kt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'opendc-core') 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 c89bdb59..13170256 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 @@ -50,6 +50,14 @@ interface Context { */ val delta: Duration + /** + * The sender of the last received message or `null` in case the process has not received any messages yet. + * + * Note that this property is only guaranteed to be correct when accessing after a single suspending call. Methods + * like `hold()` and `interrupt()` may change the value of this property. + */ + val sender: Entity<*, *>? + /** * The observable state of the entity bound to this scope. */ -- cgit v1.2.3