Module Sarek_execute.Policy_stamp

The policy a memoised, policy-dependent result was computed under (specs/optimisation-policy.md, cache rule).

A stamp holds the Sarek_policy.version read before the policy was read and the digest of the kernel's effective policy. current is one atomic read while nothing changed; when the policy changed somewhere, it compares digests, so a grant for another kernel does not invalidate this one.

type t = {
  1. version : int Stdlib.Atomic.t;
  2. digest : string;
}
val digests : int Stdlib.Atomic.t
val digests_computed : unit -> int
val digest_of : string -> string
val make : kernel:string -> t

The stamp to take BEFORE computing the result: the version is read first, so a change racing with the computation makes the stamp stale, never wrongly current.

val current : t -> kernel:string -> bool

true when the policy of kernel is the one t was made under.

val find_current : kernel:string -> matches:('a -> bool) -> ('a * ('b * t)) list -> 'b option

The value stored under a key accepted by matches, if its stamp is current for kernel; entries are (key, (value, stamp)).

val install : matches:('a -> bool) -> ('a * ('b * 'c)) list -> 'a -> 'b -> 'c -> ('a * ('b * 'c)) list

entries with the entry for the key replaced (a stale one is dropped, not shadowed).