Module Prime_beacon.Make
Create a beacon API for based on the given metrics. The resulting module contains globals and registers a Gc.alarm, so it is recommended to use a single or a few global instances.
Parameters
Signature
type tThe 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 -> unitval dummy : tA dummy beacon. This is useful for temporary objects used as lookup keys for weak maps.
val embed : float -> (t -> 'a) -> 'aembed g fpasses a suitable beacon of gradegtof, 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 asgis greater than the memory pressure times the access period. One access is recorded upon construction.
val grade : t -> floatgrade xis the current grade ofx.
val set_grade : float -> t -> unitset_grade g xsets the grade ofxtog.
val charge : t -> unitcharge brecords the fact thatbhas 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