4.1. Channels

Orc has no communication primitives like pi-calculus channels[1] or Erlang mailboxes[2]. Instead, it makes use of sites to create channels of communication.

The most frequently used of these sites is Channel. When called, it publishes a new asynchronous FIFO channel. That channel is a site with two methods: get and put. The call c.get() takes the first value from channel c and publishes it, or blocks waiting for a value if none is available. The call c.put(v) puts v as the last item of c and publishes a signal.

A channel may be closed to indicate that it will not be sent any more values. If the channel c is closed, c.put(v) always halts (without modifying the state of the channel), and c.get() halts once c becomes empty. The channel c may be closed by calling either c.close(), which returns a signal once c becomes empty, or c.closeD(), which returns a signal immediately.

[1] Robin Milner. 1999. Communicating and Mobile Systems: The π-Calculus. Cambridge University Press, New York, NY, USA.

[2] Joe Armstrong, Robert Virding, Claes Wikström, and Mike Williams. 1996. Concurrent programming in ERLANG (2nd ed.). Prentice Hall, Englewood Cliffs, NJ, USA.