Synchronous sends
Message-passing concurrency

Prev:Sending and receiving messages
Next:Linked exceptions


The send word sends a message asynchronously, and the sending thread continues immediately. It is also possible to send a message to a thread and block until a response is received:
send-synchronous ( message thread -- reply )


To reply to a synchronous message:
reply-synchronous ( message synchronous -- )

handle-synchronous ( quot: ( ... message -- ... reply ) -- )


An example:
USING: concurrency.messaging threads ; IN: scratchpad : pong-server ( -- ) [ drop "pong" ] handle-synchronous ; [ pong-server t ] "pong-server" spawn-server "ping" swap send-synchronous .
"pong"