2008-03-14 12:16:04 -06:00
|
|
|
type t
|
|
|
|
(** The type of event dispatchers *)
|
|
|
|
|
2009-02-08 22:26:27 -07:00
|
|
|
type event = Input | Output | Exception
|
2008-03-14 12:16:04 -06:00
|
|
|
(** An event associated with a file descriptor *)
|
|
|
|
|
2009-02-08 22:26:27 -07:00
|
|
|
type fd_handler = Unix.file_descr -> event -> unit
|
|
|
|
(** [fd_handler fd evt] handles event [evt] from file descriptor [fd] *)
|
2008-03-14 12:16:04 -06:00
|
|
|
|
2008-03-15 19:46:06 -06:00
|
|
|
type timer_handler = float -> unit
|
2009-02-08 22:26:27 -07:00
|
|
|
(** [timer_handler d when] is called at or after [when] *)
|
2008-03-14 12:16:04 -06:00
|
|
|
|
2010-12-10 17:03:24 -07:00
|
|
|
val create : unit -> t
|
|
|
|
(** Create a new event dispatcher. *)
|
2008-03-14 12:16:04 -06:00
|
|
|
|
|
|
|
val destroy : t -> unit
|
|
|
|
(** Destroy an event dispatcher *)
|
|
|
|
|
|
|
|
val add : t -> Unix.file_descr -> fd_handler -> event list -> unit
|
|
|
|
(** [add d fd handler events] begins listening for [events] on file
|
|
|
|
descriptor [fd], calling [handler] when an event occurs. *)
|
|
|
|
|
2008-03-15 19:46:06 -06:00
|
|
|
val modify : t -> Unix.file_descr -> event list -> unit
|
2008-03-16 21:43:21 -06:00
|
|
|
(** [modify d fd events] changes the events to pay attention to on [fd] *)
|
2008-03-14 12:16:04 -06:00
|
|
|
|
|
|
|
val set_handler : t -> Unix.file_descr -> fd_handler -> unit
|
|
|
|
(** [set_handler d fd handler] changes the handler to be invoked for
|
|
|
|
events on [fd] *)
|
|
|
|
|
|
|
|
val delete : t -> Unix.file_descr -> unit
|
|
|
|
(** [delete d fd] stops [d] paying attention to events on file
|
|
|
|
descriptor [fd] *)
|
|
|
|
|
2008-03-16 21:43:21 -06:00
|
|
|
val add_timer : t -> timer_handler -> float -> unit
|
2008-03-15 19:46:06 -06:00
|
|
|
(** [add_timer d time handler] will cause dispatcher [d] to invoke
|
2008-03-14 12:16:04 -06:00
|
|
|
[handler d time] at or after [time] *)
|
|
|
|
|
2008-03-15 19:46:06 -06:00
|
|
|
val delete_timer : t -> float -> unit
|
|
|
|
(** [delete_timer d time] prevents dispatcher from invoking any
|
2008-03-14 12:16:04 -06:00
|
|
|
handlers added for [time] *)
|
|
|
|
|
|
|
|
val once : t -> unit
|
|
|
|
(** [once d] will dispatch one event (or set of simultaneous events)
|
|
|
|
added to [d]. *)
|
|
|
|
|
|
|
|
val run : t -> unit
|
|
|
|
(** [run d] will dispatch events from [d] until all file descriptors
|
2008-03-15 19:46:06 -06:00
|
|
|
have been removed and all timers have run or been removed *)
|