module Duppy:sig
..end
The bars could not hold me; Force could not control me now. They try to keep me down, yeah! But Jah put I around. (...) Let me tell you this - I'm a duppy conqueror !
Duppy
is a task scheduler for ocaml. It implements a wrapper
around Unix.select
.
Using Duppy.Task
, the programmer can easily submit tasks that need to wait
on a socket even, or for a given timeout (possibly zero).
With Duppy.Async
, one can use a scheduler to submit asynchronous tasks.
Duppy.Io
implements recursive easy reading and writing to a Unix.file_descr
Finally, Duppy.Monad
and Duppy.Monad.Io
provide a monadic interface to
program server code that with an implicit return/reply execution flow.
The scheduler can use several queues running concurently, each queue
processing ready tasks. Of course, a queue should run in its own thread.
type 'a
scheduler
'a
is the type of objects used for priorities.
val create : ?compare:('a -> 'a -> int) -> unit -> 'a scheduler
compare
: the comparison function used to sort tasks according to priorities.
Works as in List.sort
val queue : ?log:(string -> unit) ->
?priorities:('a -> bool) -> 'a scheduler -> string -> unit
queue ~log ~priorities s name
starts a queue, on the scheduler s
only processing priorities p
for which priorities p
returns true
.
Several queues can be run concurrently against s
.
log
: Logging function. Default: Printf.printf "queue %s: %s\n" name
priorities
: Predicate specifying which priority to process. Default: fun _ -> _ -> true
An exception is raised from this call when duppy's event loops has crashed. This exception should be considered a MAJOR FAILURE. All current non-ready tasks registered for the calling scheduler are dropped. You may restart Duppy's queues after it is raised but it should only be used to terminate the process diligently!!
val stop : 'a scheduler -> unit
module Task:sig
..end
module Async:sig
..end
module Io:sig
..end
Unix.file_descr
.
module Monad:sig
..end
Duppy.Io
.