module Duppy:sig
..end
Advanced scheduler and monad for server-oriented programming.
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 scheduler is a device for processing tasks. Several queues might run in different threads, processing one scheduler's tasks.
'a
is the type of objects used for priorities.
val create : ?compare:('a -> 'a -> int) -> unit -> 'a scheduler
Initiate a new 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
Stop all queues running on that scheduler, causing them to return.
module Task:sig
..end
Core task registration.
module Async:sig
..end
Asynchronous task module
module type Transport_t =sig
..end
Module type for Io functor.
module type Io_t =sig
..end
Easy parsing of Unix.file_descr
.
module MakeIo:
module Io:Io_t
with type socket = Unix.file_descr
module Monad:sig
..end
Monadic interface to Duppy.Io
.
Duppy is a Caribbean patois word of West African origin meaning ghost or spirit. Much of Caribbean folklore revolves around duppies. Duppies are generally regarded as malevolent spirits. They are said to come out and haunt people at night mostly, and people from the islands claim to have seen them. The 'Rolling Calf', 'Three footed horse' or 'Old Higue' are examples of the more malicious spirits.