Module type Prime_beacon.S
type t
The type of a field to embed in records in order to keep track of access and prevent actively used data from being garbage collected.
val expire_all : unit -> unit
val dummy : t
A dummy beacon. This is useful for temporary objects used as lookup keys for weak maps.
val embed : float -> (t -> 'a) -> 'a
embed g f
passes a suitable beacon of gradeg
tof
, which is expected to construct and return an object embedding the beacon. Conversely, the returned object is made accessible from the beacon, which itself is kept visible to the garbage collector as long asg
is greater than the memory pressure times the access period. One access is recorded upon construction.
val grade : t -> float
grade x
is the current grade ofx
.
val set_grade : float -> t -> unit
set_grade g x
sets the grade ofx
tog
.
val charge : t -> unit
charge b
records the fact thatb
has just been accessed. This is typically called each time an object is acquired from a weak data structure.
val cache_metric : Prime_cache_metric.t