The Concurrent ML Reference Manual


The Multicast structure

Multicast channels provide a mechanism for broadcasting a stream of messages to a collection of threads. Threads receive multicast messages via an output port; each port receives its own copy of every message sent since the port was created. Multicast channels are particularly useful for communicating with a dynamically varying group of threads, since the sender does not need to know how many threads are listening.


Synopsis

signature MULTICAST
structure Multicast : MULTICAST

Interface

type 'a event = 'a CML.event
type 'a mchan
type 'a port
val mChannel : unit -> 'a mchan
val port : 'a mchan -> 'a port
val copy : 'a port -> 'a port
val recv : 'a port -> 'a
val recvEvt : 'a port -> 'a event
val multicast : ('a mchan * 'a) -> unit

Description

type 'a event

type 'a mchan
This is the type constructor for asynchronous multicast channels.

type 'a port
This is the type constructor for output ports on an asynchronous multicast channels.

mChannel ()
creates a new multicast channel.

port mc
creates a new output port on the channel mc. The port receives those messages sent after it is created.

copy p
creates a new output port on a channel that has the same state as the port p. I.e., the stream of messages seen on the two ports will be the same. This is useful when two threads need to see the same stream of messages. NOTE: if two (or more) independent threads are reading from p at the time that copy operation is performed, then it may not be accurate.

recv p
gets the next message from the port p. The calling thread is blocked until there is a message available.

recvEvt p
creates an event value that represents the recv operation on the port p.

multicast (mc, v)
multicasts the value v on the channel mc. This is a nonblocking operation.



[ INDEX | TOP | Parent | Root ]

Last Modified January 29, 1997
Copyright © 1996 AT&T


Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: > <I>Last Modified January 29, 1997</I><BR> Copyright &copy; 1996 AT&amp;T <BR> <HR> </BODY> </HTML>