CML
structure
signature CML
structure CML
: CML
type thread_id
type 'a chan
type 'a event
val version : {
system : string,
version_id : int list,
date : string
}
val banner : string
val spawnc : ('a -> unit) -> 'a -> thread_id
val spawn : (unit -> unit) -> thread_id
val yield : unit -> unit
val exit : unit -> 'a
val getTid : unit -> thread_id
val sameTid : thread_id * thread_id -> bool
val compareTid : thread_id * thread_id -> order
val hashTid : thread_id -> word
val tidToString : thread_id -> string
val joinEvt : thread_id -> unit event
val channel : unit -> 'a chan
val sameChannel : 'a chan * 'a chan -> bool
val send : 'a chan * 'a -> unit
val recv : 'a chan -> 'a
val sendEvt : 'a chan * 'a -> unit event
val recvEvt : 'a chan -> 'a event
val sendPoll : 'a chan * 'a -> bool
val recvPoll : 'a chan -> 'a option
val wrap : 'a event * ('a -> 'b) -> 'b event
val wrapHandler : 'a event * (exn -> 'a event) -> 'a event
val guard : (unit -> 'a event) -> 'a event
val withNack : (unit event -> 'a event) -> 'a event
val choose : 'a event list -> 'a event
val sync : 'a event -> 'a
val select : 'a event list -> 'a
val never : 'a event
val alwaysEvt : 'a -> 'a event
val timeOutEvt : Time.time -> unit event
val atTimeEvt : Time.time -> unit event
type thread_id
compareTid
).
type 'a chan
type 'a event
val version : {
system : string,
version_id : int list,
date : string
}
val banner : string
spawnc f x
spawn f
val yield : unit -> unit
exit ()
getTid ()
sameTid (tid1, tid2)
true
, if the two thread IDs are the same ID.
compareTid (tid1, tid2)
hashTid tid
tidToString tid
joinEvt tid
spawn
(or spawnc
) may return; it may call the exit
function, or it may have an uncaught exception. Note that joinEvt
does not distinguish between these cases; it also does not become enabled if the named thread deadlocks (even if it is garbage collected).
channel ()
sameChannel (ch1, ch2)
true
, if the two channels are the same channel.
send (ch, msg)
recv ch
val sendEvt : 'a chan * 'a -> unit event
val recvEvt : 'a chan -> 'a event
send
and recv
operations.
sendPoll (ch, msg)
true
is returned. Otherwise, no communication is preformed and false
is returned. This function is not recommended for general use; it is provided as an efficiency aid for certain kinds of protocols.
recvPoll ch
send
a message on ch, then this returns NONE
, otherwise it returns SOME
wrapped around the message. This function is not recommended for general use; it is provided as an efficiency aid for certain kinds of protocols.
wrap (ev, f)
wrapHandler (ev, h)
guard
and withNack
) are not handled by h.
guard g
withNack g
guard
, the function g will be evaluated at synchronization time and the resulting event value will be used in its place in the synchronization. Furthermore, when g is evaluated, it is passed a negative acknowledgement event as an argument. This negative acknowledgement event is enabled in the case where some other event involved in the synchronization is chosen instead of the one produced by g. The withNack
combinator provides a mechanism for informing servers that a client has aborted a transaction.
choose evs
sync ev
select evs
sync (choose evs)but is more efficient.
never
choose []
alwaysEvt x
timeOutEvt t
sync (timeOutEvt (Time.fromSeconds 1))will delay the calling thread for one second. Note that the specified time interval is actually a minimum waiting time, and the delay may be longer.
atTimeEvt t
sync (atTimeEvt (Date.toTime (Date.date { year = 2000, month = Date.Jan, day = 0, hour = 0, minute = 0, second = 0, offset = NONE })))blocks the calling thread until the beginning of the year 2000.
Option
,Time
Last Modified &date;
Comments to John Reppy.
Copyright © 1991-2003 John Reppy