Module CCTimer
Event timer
Used to be part of CCFuture
.
- since
- 0.16
val create : unit -> t
A new timer.
val set_exn_handler : t -> (exn -> unit) -> unit
set_exn_handler timer f
registersf
so that any exception raised by a task scheduled intimer
is given tof
.
val after : t -> float -> f:(unit -> _) -> unit
Call the callback
f
after the given number of seconds.- raises Stopped
if the timer was stopped.
val at : t -> float -> f:(unit -> _) -> unit
Create a future that evaluates to
()
at the given Unix timestamp.- raises Stopped
if the timer was stopped.
val every : ?delay:float -> t -> float -> f:(unit -> _) -> unit
every timer n ~f
callsf ()
everyn
seconds.f()
can raise ExitEvery to stop the cycle.- parameter delay
if provided, the first call to
f ()
is delayed by that many seconds.
- raises Stopped
if the timer was stopped.
val stop : t -> unit
Stop the given timer, cancelling pending tasks. Idempotent. From now on, calling most other operations on the timer will raise Stopped.
val active : t -> bool
Return
true
untilstop t
has been called.