Module Duppy


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 !
       
Lee "Scratch" Perry & Bob Marley - Duppy conqueror

Duppy task scheduler for OCaml.

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

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
val stop : 'a scheduler -> unit
Stop all queues running on that scheduler, causing them to return.
module Task: sig .. end
module Async: sig .. end
module Io: sig .. end

Some culture..

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.
http://en.wikipedia.org/wiki/Duppy