diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-01-19 21:59:39 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-01-19 21:59:39 +0100 |
| commit | 878990c8e230a43b534fc8e870f59630152fb6bf (patch) | |
| tree | 8fafdab0235e3ce09c8ef38520853ac60b290505 /odcsim/odcsim-api | |
| parent | efb31902e6950f52ba8b50c2472f867e6d98313b (diff) | |
feat: Add support for selecting on receive ports
This change adds experimental support for selecting on ports. This
allows the user to receive messages from multiple channels at the same
time.
Diffstat (limited to 'odcsim/odcsim-api')
| -rw-r--r-- | odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt b/odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt index 30d4790c..7c730866 100644 --- a/odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt +++ b/odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt @@ -24,6 +24,8 @@ package com.atlarge.odcsim +import kotlinx.coroutines.selects.SelectClause1 + /** * A communication endpoint of a specific logical process through which messages pass. * @@ -48,6 +50,11 @@ public interface ReceivePort<out T : Any> : Port { * Receive a message send to this port or suspend the caller while no messages have been received at this port yet. */ public suspend fun receive(): T + + /** + * Clause for select expression for receiving a message from the channel. + */ + val onReceive: SelectClause1<T> } /** |
