281 lines
4.0 KiB
HTML
281 lines
4.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Event</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Event</H1>
|
|
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Event - First-class synchronous communication.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Event
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Event</B>
|
|
|
|
<BR> :
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
First-class synchronous communication.
|
|
<P>
|
|
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.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>type </I>
|
|
|
|
<B>'a</B>
|
|
|
|
<I>channel </I>
|
|
|
|
<P>
|
|
<P>
|
|
The type of communication channels carrying values of type
|
|
<B>'a</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val new_channel </I>
|
|
|
|
:
|
|
<B>unit -> 'a channel</B>
|
|
|
|
<P>
|
|
Return a new channel.
|
|
<P>
|
|
<P>
|
|
<I>type </I>
|
|
|
|
<B>+'a</B>
|
|
|
|
<I>event </I>
|
|
|
|
<P>
|
|
<P>
|
|
The type of communication events returning a result of type
|
|
<B>'a</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val send </I>
|
|
|
|
:
|
|
<B>'a channel -> 'a -> unit event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>send ch v</B>
|
|
|
|
returns the event consisting in sending the value
|
|
<B>v</B>
|
|
|
|
over the channel
|
|
<B>ch</B>
|
|
|
|
. The result value of this event is
|
|
<B>()</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val receive </I>
|
|
|
|
:
|
|
<B>'a channel -> 'a event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>receive ch</B>
|
|
|
|
returns the event consisting in receiving a value
|
|
from the channel
|
|
<B>ch</B>
|
|
|
|
. The result value of this event is the
|
|
value received.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val always </I>
|
|
|
|
:
|
|
<B>'a -> 'a event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>always v</B>
|
|
|
|
returns an event that is always ready for
|
|
synchronization. The result value of this event is
|
|
<B>v</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val choose </I>
|
|
|
|
:
|
|
<B>'a event list -> 'a event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>choose evl</B>
|
|
|
|
returns the event that is the alternative of
|
|
all the events in the list
|
|
<B>evl</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val wrap </I>
|
|
|
|
:
|
|
<B>'a event -> ('a -> 'b) -> 'b event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>wrap ev fn</B>
|
|
|
|
returns the event that performs the same communications
|
|
as
|
|
<B>ev</B>
|
|
|
|
, then applies the post-processing function
|
|
<B>fn</B>
|
|
|
|
on the return value.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val wrap_abort </I>
|
|
|
|
:
|
|
<B>'a event -> (unit -> unit) -> 'a event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>wrap_abort ev fn</B>
|
|
|
|
returns the event that performs
|
|
the same communications as
|
|
<B>ev</B>
|
|
|
|
, but if it is not selected
|
|
the function
|
|
<B>fn</B>
|
|
|
|
is called after the synchronization.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val guard </I>
|
|
|
|
:
|
|
<B>(unit -> 'a event) -> 'a event</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>guard fn</B>
|
|
|
|
returns the event that, when synchronized, computes
|
|
<B>fn()</B>
|
|
|
|
and behaves as the resulting event. This enables
|
|
computing events with side-effects at the time of the synchronization
|
|
operation.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sync </I>
|
|
|
|
:
|
|
<B>'a event -> 'a</B>
|
|
|
|
<P>
|
|
'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.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val select </I>
|
|
|
|
:
|
|
<B>'a event list -> 'a</B>
|
|
|
|
<P>
|
|
'Synchronize' on an alternative of events.
|
|
<B>select evl</B>
|
|
|
|
is shorthand for
|
|
<B>sync(choose evl)</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val poll </I>
|
|
|
|
:
|
|
<B>'a event -> 'a option</B>
|
|
|
|
<P>
|
|
Non-blocking version of
|
|
<B>Event.sync</B>
|
|
|
|
: offer all the communication
|
|
possibilities specified in the event to the outside world,
|
|
and if one can take place immediately, perform it and return
|
|
<B>Some r</B>
|
|
|
|
where
|
|
<B>r</B>
|
|
|
|
is the result value of that communication.
|
|
Otherwise, return
|
|
<B>None</B>
|
|
|
|
without blocking.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">Module</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:39 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|