summaryrefslogtreecommitdiff
path: root/opendc-core/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2018-02-16 14:39:53 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2018-02-16 14:46:40 +0100
commitb84a995a05fecb9ef90c9184959f285f324e7411 (patch)
tree88ef342f7b5cc64350a0a76fb2c5e192171ebc02 /opendc-core/src
parent2fa0134773a99394aae0efc167af6767e2828c71 (diff)
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.
Diffstat (limited to 'opendc-core/src')
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt8
1 files changed, 8 insertions, 0 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 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
@@ -51,6 +51,14 @@ interface Context<S, out M> {
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.
*/
var state: S