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

Type of a TLS key

val new_key : ?split_from_parent:('a -> unit -> 'a) @ portable -> (unit -> 'a) @ portable -> 'a Thread.TLS.key @@ portable

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

val get : 'a. 'a Thread.TLS.key -> 'a @ contended @@ portable

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

val set : 'a. 'a Thread.TLS.key -> 'a @ portable -> unit @@ portable

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