module Cf_poll:I/O event multiplexing.sig..end
This module implements an abstraction useful for multiplexing I/O events within a single thread of control. Use this module in cases when a program must block until an I/O event is ready at one of a collection of system resources.
Note: On some platforms in the future, this module may be implemented
around a specialized kernel event queue, e.g. /dev/poll on Solaris, or
kevent/kqueue on Mac OS X. In this early implementation, however, the
module is implemented as a wrapper around Unix.select on all platforms.
type t
type more =
| |
More |
| |
Last |
type 'a state =
| |
Unloaded |
| |
Loaded of |
| |
Working of |
| |
Final of |
| |
Exception of |
`Unloaded, not loaded into a polling event queue.`Loaded q, loaded into the polling event queue q.`Final v finished with a normal result v.`Exception x, finished with an exceptional result x.class type virtual['a]event =object..end
'a.
exception Not_ready
get method is applied to an I/O event
object that has not been serviced by a polling mux.To use a polling mux, follow these steps:
create ();file, signal, time and idle I/O events;load method on each one using the new mux;cycle function to the mux;canget and get methods to the events to obtain the results.val create : unit -> tcreate () to construct a new polling mux.val cycle : t -> morecycle p to wait until one or more of the I/O event objects loaded
into the mux p is ready to be serviced, then service them (which includes
invoking their obj#service method). Returns Last if there are no more
events loaded into the polling mux. Otherwise, returns More.typerwx =[ `R | `W | `X ]
class virtual['a]file :[< rwx ] -> Unix.file_descr ->['a]event
inherit file rwx fd to derive an I/O event object that waits for the
file descriptor fd to be ready for reading, writing, or exception
(according to the value of rwx).
class virtual['a]signal :int ->['a]event
inherit signal n to derive an I/O event that is serviced when the
system delivers the signal n.
class virtual['a]time :?t0:Cf_tai64n.t -> float ->object..end
inherit time ?start interval to derive an I/O event that is
serviced after the system clock reaches a specific time and at constrant
intervals thereafter.
class virtual['a]idle :object..end
inherit idle to derive an I/O event that is serviced whenever a
polling mux cycle would otherwise block for any non-zero length of time.