module Liboevent:sig..end
The Ocaml Event library provides an interface to the event API.
The event API provides a mechanism to execute a function when a specific event on a file descriptor occurs or after a given time has passed.
This library is a wrapper of the libevent API made by Nils Provos. For more information about this library see: http://www.monkey.org/~provos/libevent.
Currently, libevent supports kqueue(2), select(2), poll(2) and epoll(4). Support for /dev/poll is planned.
type event
The type of events
type event_flags =
| |
TIMEOUT |
(* | A timeout occurred. | *) |
| |
READ |
(* | A read is possible. | *) |
| |
WRITE |
(* | A write operation is possible. | *) |
| |
SIGNAL |
(* | A signal occurred. | *) |
The possible event types
typeevent_callback =Unix.file_descr -> event_flags -> unit
The type of event callbacks
val create : unit -> eventCreate a new empty event
val fd : event -> Unix.file_descrfd event returns the file descriptor associated with the event
val signal : event -> intsignal event returns the signal associated with the event
val set : event ->
Unix.file_descr ->
event_flags list ->
persist:bool -> event_callback -> unitset event fd type persist callback initializes the event. The
flag persist makes an event persitent until Libevent.del is
called.
val set_signal : event ->
signal:int -> persist:bool -> event_callback -> unitset_signal event signal persist callback initializes the event. The
flag persist makes an event persistent unit Libevent.del is
called.
val add : event -> float option -> unitadd event timeout adds the event and schedules the execution
of the function specified with Libevent.set, or in at least the
time specified in the timeout. If timeout is None, no
timeout occures, and the function will only be called if a
matching event occurs on the file descriptor.
val del : event -> unitDel the event
val pending : event -> event_flags list -> boolval dispatch : unit -> unitIn order to process events, an application needs to call dispatch. This * function only returns on error, and should replace the event core of the * application
type loop_flags =
| |
ONCE |
| |
NONBLOCK |
val loop : loop_flags -> unitProvides an interface for single pass execution of pending events