receiveMessage

suspend fun <M : AgentMessage> KSLProcessBuilder.receiveMessage(mailbox: AgentModel.AgentMailbox<M>, suspensionName: String? = null, predicate: (M) -> Boolean = { true }): M(source)

Suspend until a message matching predicate is available in mailbox, then return it. Default predicate matches anything.

If pending already contains a matching message, returns it immediately without suspending. Otherwise the calling entity is parked via a per-call ksl.modeling.entity.ProcessModel.Entity.Suspension, and the matching sendMessage from another agent will resume it directly.

A receiver whose process is terminated after a message was handed to it, and before it resumed to take it, hands the message back: it goes to the next waiting receiver that accepts it, or waits in the mailbox ahead of the messages already there.