Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
Consider the two functions :
Foo <:: {* msj << i++; {? ?msj ?}; msj << j++; {? ?msj ?}; *};
and Bar <:: {* {? msj? ?}; msj =>> x; ttyout x; *};
Foo alternately increments i and j, and sends it as a message to Bar, and Bar waits for a message and prints it. Foo has two independent sequential phases : increment i, wait for Bar to receive the message, increment j, wait for Bar to receive the message; then loop back and do it again. Bar repeatedly waits for a message and then prints it. Typically these two functions would run concurrently, on separate threads thus :
{! Foo; Bar !};
{? ?msj ?} waits for msj to become empty, and {? msj? ?} waits for msj to become full. These acheives a coroutine rendezvous mechanism, sometimes known as a "producer/consumer pair".