Module Cf_poll


module Cf_poll: sig .. end
I/O event multiplexing.


Overview

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.

Types

type t 
A polling mux.

type more_t =
| More
| Last
The sum type of results from cycling a polling mux.
type 'a state_t = [ `Exception of exn | `Final of 'a | `Loaded of t | `Unloaded ] 
The basic polymorphic sum type for the state of an I/O event. Specializations of the basic I/O event class type may need more states. The basic states are:
class type virtual [[> 'a state_t ]] event = object .. end
The type of objects representing an I/O events that produce results of type 'a.
exception Not_ready
The exception raised when the get method is applied to an I/O event object that has not been serviced by a polling mux.

Functions and Classes

To use a polling mux, follow these steps:


val create : unit -> t
Use create () to construct a new polling mux.
val cycle : t -> more_t
Use cycle 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.
type 'a file_state_t = [ `Exception of exn
| `Final of 'a
| `Loaded of t
| `Unloaded
| `Working of t * 'a ]
File events have a state that represents an intermediate result while the event is still loaded in the mux.
type rwx_t = [ `R | `W | `X ] 
File events are associated with read, write or exception I/O events.
class virtual [[> 'a file_state_t ]] file : [< rwx_t ] -> Unix.file_descr -> object .. end
Use 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 state_t ]] signal : int -> [[> 'a state_t ] as 'b] event
Use inherit signal n to derive an I/O event that is serviced when the system delivers the signal n.
class virtual [[> 'a state_t ]] time : Cf_tai64n.t -> object .. end
Use inherit time epoch to derive an I/O event that is serviced when the system clock reaches the time epoch.
class virtual [[> 'a state_t ]] idle : object .. end
Use 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.