package timed
-
timed.compat
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Timed references for Stdlib.ref
. This module redefines the all the functions used to update references, and enables the restoration of saved reference states.
Note that this module allocates one blocks of memory at initialization for its internal state. It occupies a total of four words.
val (:=) : 'a ref -> 'a -> unit
r := v
sets the value of the reference r
to v
. This operation has a very small overhead compared to Stdlib.((:=))
if no time has been via Time.save
. Nonetheless, it is always constant time, and allocation is only necessary if the current “time” is accessible (or not reclaimed by the garbage-collector). When that is the case, three blocks of memory are allocated, for a total of eight words.
val incr : int ref -> unit
incr r
is equivalent to r := !r + 1
.
val decr : int ref -> unit
decr r
is equivalent to r := !r - 1
.
module Time : sig ... end
The Time
module provides an abstract representation of time, used to set a point from which (monitored) updates to references are recorded to allow undoing/redoing the corresponding changes.
pure_apply f v
computes the result of f v
, but reverts the (monitored) updates made to references in the process before returning the value.