package sel
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Sel
Source
Simple event library - No asymc monads, No threads, No exceptions
System events one can wait for
val on_bytes :
Unix.file_descr ->
int ->
(Bytes.t res -> 'a) ->
'a event * cancellation_handle
val on_queues :
'b Queue.t ->
'c Queue.t ->
('b -> 'c -> 'a) ->
'a event * cancellation_handle
Synchronization events between components (worker pool and a task queue)
A way to feed the event queue
for debug printing
a recurrent event is never removed from the todo set, that is, when ready a copy of it is added back automatically
a recurrent event is never removed from the todo set, that is, when ready a copy of it is added back automatically
convenience adaptor to drop the cancellation handle
convenience adaptor to drop the cancellation handle
it is unusual to make a regular computation cancellable, hence the event constructor does not recurn the cancellation handle. Here the way to recover it
it is unusual to make a regular computation cancellable, hence the event constructor does not recurn the cancellation handle. Here the way to recover it
lower integers correspond to hight priorities (as in Unix nice)
lower integers correspond to hight priorities (as in Unix nice)
The main loop goes like this
type top_event = | NotForMe of Component.event | Echo of string
let echo : top_event event = on_line Unix.stdin (function | Ok s -> Echo s | Error _ -> Echo "error") |> uncancellable |> make_recurrent
let handle_event = function | NotForMe e -> List.map (map (fun x -> NotForMe x)) (Component.handle_event e) | Echo text -> Printf.eprintf "echo: %s\n" text;
let rec loop evs = let ready, evs = pop evs in let new_evs = handle_event ready in loop (enqueue evs new_evs)
let main () = loop (enqueue empty echo; ...
)