val new_channel : unit -> 'a channel
Return a new channel.
val send : 'a channel -> 'a -> unit event
send ch v
returns the event consisting in sending the valuev
over the channelch
. The result value of this event is()
.
val receive : 'a channel -> 'a event
receive ch
returns the event consisting in receiving a value from the channelch
. The result value of this event is the value received.
val always : 'a -> 'a event
always v
returns an event that is always ready for synchronization. The result value of this event isv
.
val choose : 'a event list -> 'a event
choose evl
returns the event that is the alternative of all the events in the listevl
.
val wrap : 'a event -> ('a -> 'b) -> 'b event
wrap ev fn
returns the event that performs the same communications asev
, then applies the post-processing functionfn
on the return value.
val wrap_abort : 'a event -> (unit -> unit) -> 'a event
wrap_abort ev fn
returns the event that performs the same communications asev
, but if it is not selected the functionfn
is called after the synchronization.
val guard : (unit -> 'a event) -> 'a event
guard fn
returns the event that, when synchronized, computesfn()
and behaves as the resulting event. This enables computing events with side-effects at the time of the synchronization operation.
val sync : 'a event -> 'a
'Synchronize' on an event: offer all the communication possibilities specified in the event to the outside world, and block until one of the communications succeed. The result value of that communication is returned.
val select : 'a event list -> 'a
'Synchronize' on an alternative of events.
select evl
is shorthand forsync(choose evl)
.
val poll : 'a event -> 'a option
Non-blocking version of
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 returnSome r
wherer
is the result value of that communication. Otherwise, returnNone
without blocking.