jon.recoil.org

Module Thread.TLS

Thread-local storage. Like Domain.DLS, but stores a distinct value for each thread. Domains can contain multiple threads, so TLS should be preferred in nearly all cases.

type 'a key : value mod portable contended

Type of a TLS key

val new_key : ?split_from_parent:('a -> (unit -> 'a) @ once portable) @ portable -> (unit -> 'a) @ portable -> 'a key @@ portable

Like DLS.new_key, but represents a distinct value in every thread.

val get : ('a : value mod portable). 'a key -> 'a @ contended @@ portable

Like DLS.get, but reads the value for the current thread.

val set : ('a : value mod contended). 'a key -> 'a @ portable -> unit @@ portable

Like DLS.set, but sets the value for the current thread.