Docs GODI Archive
Projects Blog Knowledge

Look up function:

(e.g. "List.find" or "keysym")
More options

Class type Unixqueue.event_system

class type event_system = object .. end
The event_system manages events, handlers, resources, groups, etc. It is now a class type, and you may invoke the operations directly for the class. The operations are still available as functions (below).

A resource is an operation with an optional timer. The operation describes the condition to watch for, and the timer defines the maximum period of time for that. If the condition becomes true, an Input_arrived, Output_readiness, or Out_of_band event will be triggered. If the timer expires, a Timeout event will be generated. After the event the resource remains active, and the timeout period begins anew.

A resource is usually bound to a file descriptor. It is allowed to watch the same descriptor for several different conditions, but it is forbidden to watch the same descriptor for the same kind of condition several times.

As a special case, the operation Wait is not bound to a file descriptor, but simply starts a timer. The argument of Wait can be used to distinguish between several timers that are active at the same time.

Event handlers get the events one after the other, and process them. When a handler is called for an event, there are several possible reactions: (1) The handler can return normally, which means that the event has been accepted, and will not be passed to any other handler. (2) The handler can raise Equeue.Reject, which means that the handler cannot process the event, and that another handler should get it. (3) The handler can raise Equeue.Terminate which means that the event has been accepted, and that the handler is terminated (it will never be called again). (4) The handler can raise Abort which means that the event is deferred, and that a special abort mechanism is triggered (see the description for Abort above), this is also terminates the handler. The deferred event will again be processed in the future. (5) The handler can raise any other exception. This causes that the event is deferred, and the exception falls through to the caller of run.

Groups are used to simplify the association of events to handlers, and to simplify the termination of handlers (see clear). If an event is associated with a group, only handlers associated with the same group will get them.

There is a special Close handler which is useful to close file descriptors no longer needed. It is called when all resources are removed from the event system dealing with the file descriptor. The close handler should close the descriptor. Note that close handlers are only useful under certain circumstances.

method new_group : unit -> group
method new_wait_id : unit -> wait_id
method exists_resource : operation -> bool
method add_resource : group -> operation * float -> unit
method add_close_action : group -> Unix.file_descr * (Unix.file_descr -> unit) -> unit
method add_abort_action : group -> (group -> exn -> unit) -> unit
method remove_resource : group -> operation -> unit
method add_handler : group ->
(event_system ->
event Equeue.t -> event -> unit) ->
method add_event : event -> unit
method clear : group -> unit
method run : unit -> unit
method is_running : bool
method once : group -> float -> (unit -> unit) -> unit
method exn_log : ?suppressed:bool ->
?to_string:(exn -> string) -> ?label:string -> exn -> unit
method debug_log : ?label:string -> string -> unit
method private setup : unit ->
Unix.file_descr list * Unix.file_descr list * Unix.file_descr list * float
method private queue_events : Unix.file_descr list * Unix.file_descr list * Unix.file_descr list -> bool
method private source : event Equeue.t -> unit
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml