package ambient-context

  1. Overview
  2. Docs
Abstraction over thread-local / continuation-local storage mechanisms for communication with transitive dependencies

Install

Dune Dependency

Authors

Maintainers

Sources

v0.1.0.tar.gz
md5=0171c39c3b15aa567df33792d177314a
sha512=0ef177d42e120fb174350ebc9db7d87106d9509d0c9f7f49dfce3bbf424259a1ec8f9bbf1b6a8faecff10544a7530a5d1d4d2fffdfc3f4a39c34c119540a28b2

doc/ambient-context.thread_local/Ambient_context_thread_local/Thread_local/index.html

Module Ambient_context_thread_local.Thread_localSource

Thread/Domain local storage

This allows the creation of global state that is per-domain or per-thread.

Sourcetype 'a t
Sourceval create : unit -> 'a t

Create new storage

Sourceval get : 'a t -> 'a option

Get current value

Sourceval get_exn : 'a t -> 'a

Like get but fails with an exception

Sourceval set : 'a t -> 'a -> unit
Sourceval remove : _ t -> unit
Sourceval get_or_create : create:(unit -> 'a) -> 'a t -> 'a
Sourceval with_ : 'a t -> 'a -> ('a option -> 'b) -> 'b

with_ var x f sets var to x for this thread, calls f prev where prev is the value currently in var (if any), and then restores the old value of var for this thread.

OCaml

Innovation. Community. Security.