1
(* $Id: netsys_signalling.mli 1160 2007-12-03 00:10:15Z gerd $ *)
3
(** Signalling between threads in a poll-compatible way *)
5
(** We define here an abstraction that can be both used on Unix and
6
Win32 to signal special conditions between threads. It is
7
a kind of semaphore tied to file descriptors.
10
class type sigchannel =
12
method file_descr : Unix.file_descr
13
(** A file descriptor that can be used for polling until the signal
14
arrives. One has to poll for reading.
17
method receive : unit -> unit
18
(** Receive a signal. If no signal is available, the function will block
19
until a signal arrives. One receives as many signals as have been
23
method send : unit -> unit
24
(** Send a signal. Never blocks. *)
26
method dispose : unit -> unit
27
(** Release OS resources associated with this channel. Implicitly
34
val create_sigchannel : unit -> sigchannel
35
(** Creates a new signal channel - for all platforms.
37
Unix: Signalling is implemented using a pipe. By sending a single
38
over the pipe, it is communicated that a positive number of signals
39
is available for receiving. The file desciptor can be used with
40
any form of polling (any Unix pollset will do).
42
Win32: The file descriptor is in reality a Win32 event object.
43
When a positive number of signals is available for receiving,
44
the event object is set. The file descriptor can be used with
45
[Netsys_pollset_win32.sigchannel_pollset].
47
Note that signal channels are also avaiable for single-threaded
48
programs, although they are probably not that useful there.