From 878990c8e230a43b534fc8e870f59630152fb6bf Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 19 Jan 2020 21:59:39 +0100 Subject: 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. --- odcsim/odcsim-api/src/main/kotlin/com/atlarge/odcsim/Port.kt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'odcsim/odcsim-api/src/main') 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 : 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 } /** -- cgit v1.2.3