module Event:First-class synchronous communication.
This module implements synchronous inter-thread communications over
channels. As in John Reppy's Concurrent ML system, the communication
events are first-class values: they can be built and combined
independently before being offered for communication.
val new_channel :
unit -> 'a channel
val send :
'a channel -> 'a -> unit event
send ch vreturns the event consisting in sending the value
vover the channel
ch. The result value of this event is
val receive :
'a channel -> 'a event
receive chreturns the event consisting in receiving a value from the channel
ch. The result value of this event is the value received.
val always :
'a -> 'a event
always vreturns an event that is always ready for synchronization. The result value of this event is
val choose :
'a event list -> 'a event
choose evlreturns the event that is the alternative of all the events in the list
val wrap :
'a event -> ('a -> 'b) -> 'b event
wrap ev fnreturns the event that performs the same communications as
ev, then applies the post-processing function
fnon the return value.
val wrap_abort :
'a event -> (unit -> unit) -> 'a event
wrap_abort ev fnreturns the event that performs the same communications as
ev, but if it is not selected the function
fnis called after the synchronization.
val guard :
(unit -> 'a event) -> 'a event
guard fnreturns the event that, when synchronized, computes
fn()and behaves as the resulting event. This allows to compute events with side-effects at the time of the synchronization operation.
val sync :
'a event -> 'a
val select :
'a event list -> 'a
select evlis shorthand for
val poll :
'a event -> 'a option
Event.sync: offer all the communication possibilities specified in the event to the outside world, and if one can take place immediately, perform it and return
ris the result value of that communication. Otherwise, return