module Async:sig
..end
Asynchronous task module
This module implements an asychronous API to Duppy.scheduler
It allows to create a task that will run and then go to sleep.
type
t
exception Stopped
Exception raised when trying to wake_up a task that has been previously stopped
val add : priority:'a -> 'a Duppy.scheduler -> (unit -> float) -> t
add ~priority s f
creates an asynchronous task in s
with
priority priority
.
The task executes the function f
.
If the task returns a positive float, the function will be executed
again after this delay. Otherwise it goes to sleep, and
you can use wake_up
to resume the task and execute f
again.
Only a single call to f
is done at each time.
Multiple wake_up
while previous task has not
finished will result in sequentialized calls to f
.
val wake_up : t -> unit
Wake up an asynchronous task.
Raises Stopped
if the task has been stopped.
val stop : t -> unit
Stop and remove the asynchronous task. Doesn't quit a running task.
Raises Stopped
if the task has been stopped.