module Events:sig
..end
Events
is for keeping a set of events that need to happen in the future. One can
add and remove events, and update the time to find out the events that need to
happen.module Event:sig
..end
type 'a
t
val invariant : 'a t -> unit
val create : now:Core.Std.Time.t -> 'a t
val iter : 'a t -> f:('a Event.t -> unit) -> unit
val is_empty : 'a t -> bool
val now : 'a t -> Core.Std.Time.t
val advance_clock : 'a t -> to_:Core.Std.Time.t -> [ `Not_in_the_future | `Ok of 'a list ]
advance_clock t ~to_
advances the clock to to_
, and returns `Ok values
, with
values for all events in t
with at <= to_
.
advance_clock
returns `Not_in_the_future
if Time.(<=) to_ (now t)
val add : 'a t ->
at:Core.Std.Time.t -> 'a -> [ `Not_in_the_future | `Ok of 'a Event.t ]
add t ~at value
adds a new event e
to t
with the specified value
, and returns
`Ok e
. add
returns `Not_in_the_future
if Time.(<=) at (now t)
.val remove : 'a t -> 'a Event.t -> [ `Not_present | `Removed ]
remove t event
removes event
from t
and returns `Removed
, if event
is
present in t
, else it returns `Not_present
.val next_upcoming : 'a t -> 'a Event.t option
next_upcoming t
returns the next upcoming event in t
, if any.val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
advance_clock t ~to_
advances the clock to to_
, and returns `Ok values
, with
values for all events in t
with at <= to_
.
advance_clock
returns `Not_in_the_future
if Time.(<=) to_ (now t)
add t ~at value
adds a new event e
to t
with the specified value
, and returns
`Ok e
. add
returns `Not_in_the_future
if Time.(<=) at (now t)
.
remove t event
removes event
from t
and returns `Removed
, if event
is
present in t
, else it returns `Not_present
.
next_upcoming t
returns the next upcoming event in t
, if any.