package ambient-context

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ambient-context-0.2.tbz
sha256=f451f4ed467ef0c15f472cda1021a89e96afdf3a32970ea047faf057a01c72d3
sha512=3115fd7b45ac171f7a971013dd6f32ec317fc274d800a86870a0dd43574e27b404090fbc51dae5e4c8af4961d706f84abf3843a6cf8dc57f711211cd2b547780

doc/ambient-context/Ambient_context/index.html

Module Ambient_contextSource

include module type of struct include Ambient_context_core end
Sourceval get_current_storage : unit -> Storage.t
Sourceval set_current_storage : Storage.t -> unit

Functions operating with the current storage

Sourceval get_context : unit -> Ambient_context_core.Context.t

Get the context from the current storage, or Hmap.empty if there is no ambient context.

Sourceval with_context : Ambient_context_core.Context.t -> (unit -> 'a) -> 'a

with_context ctx f calls f() in an ambient context in which get_context() will return ctx. Once f() returns, the storage is reset to its previous value.

Sourceval get : 'a Context.key -> 'a option

Get the ambient context and then look up k in it

Sourceval new_key : unit -> 'a Context.key

Create a new key

Sourceval with_key_bound_to : 'a Hmap.key -> 'a -> (unit -> 'b) -> 'b

with_key_bound_to storage k v f calls f() in a context updated to have k map to v.

Sourceval with_key_unbound : 'a Hmap.key -> (unit -> 'b) -> 'b

with_key_unbound k f calls f() in a context updated to have k bound to no value.