receive Message Or Timeout
Wait, for at most timeout time units, for a message matching predicate in mailbox.
The result is satisfied with the message if one arrives in time, or is already waiting in the mailbox (then the call returns at once). Otherwise, when the time runs out, the result is timed out, nothing is taken from the mailbox, and a matching message delivered later is kept in the mailbox as if nobody had waited. While it waits, the receiver takes its place among the mailbox's waiting receivers in the order it started waiting, as with receiveMessage, and a receiver terminated before it takes a message handed to it hands the message back in the same way.
A message delivered at the very instant the time runs out wins at the default priorities: the timer runs late in the instant. Give an earlier timeoutPriority to let the time limit win instead.
val reply = receiveMessageOrTimeout(mailbox, timeout = 5.0) { it.conversationId == convId }
if (reply.timedOut) giveUp() else handle(reply.value)Return
the message, or that the wait timed out, with the time waited
Parameters
the mailbox to receive from
the time limit; zero or more, or infinite for no limit
the priority of the event that ends the wait when the time runs out
a name for the suspension, for tracing
selects the messages to accept; by default, any message