Mailbox
structure
signature MAILBOX
structure Mailbox
: MAILBOX
The Mailbox
structure provides buffered asynchronous channels, which we call mailboxes.
type 'a mbox
val mailbox : unit -> 'a mbox
val sameMailbox : 'a mbox * 'a mbox -> bool
val send : 'a mbox * 'a -> unit
val recv : 'a mbox -> 'a
val recvEvt : 'a mbox -> 'a event
val recvPoll : 'a mbox -> 'a option
type 'a mbox
mailbox ()
sameMailbox (mb1, mb2)
true
, if mb1 and mb2 are the same mailbox.
send (mb, msg)
CML.send
, this is a non-blocking operation.
recv mb
recvEvt mb
recv
operation on mb.
val recvPoll : 'a mbox -> 'a option
recv
. If the corresponding blocking form would block (because the mailbox is empty), then this returns NONE
, otherwise it returns SOME
of the received message.
CML
Note that mailbox buffers are unbounded, which means that there is no flow control to prevent a producer from greatly outstriping a consumer, and thus exhausting memory. In situations where there is no natural limit to the rate of send
operations, it is recommended that the synchronous channels from the CML
structure be used instead.
Last Modified &date;
Comments to John Reppy.
Copyright © 1991-2003 John Reppy