jon.recoil.org

Module Capsule_expert.DataSource

Pointers to data within a capsule.

Sourcetype ('a, 'k) t

('a, 'k) t is the type of 'as within the capsule 'k. It can be passed between threads. Operations on ('a, 'k) t require a 'k Password.t associated with the capsule 'k.

Sourceval wrap : access:'k Capsule_expert.Access.t -> 'a -> ('a, 'k) Capsule_expert.Data.t @@ portable

wrap ~access v returns a pointer to the value v, which lives in the capsule 'k. 'k is always the current capsule.

Sourceval unwrap : access:'k Capsule_expert.Access.t -> ('a, 'k) Capsule_expert.Data.t -> 'a @@ portable

unwrap ~access t returns the value of t, which lives in the capsule 'k. 'k is always the current capsule.

Sourceval wrap_unique : access:'k Capsule_expert.Access.t -> 'a @ portable -> ('a, 'k) Capsule_expert.Data.t @ portable @@ portable

Like wrap, but for unique values.

Sourceval unwrap_unique : access:'k Capsule_expert.Access.t -> ('a, 'k) Capsule_expert.Data.t @ portable -> 'a @ portable @@ portable

Like unwrap, but for unique values.

Sourceval wrap_once : access:'k Capsule_expert.Access.t -> 'a @ local -> ('a, 'k) Capsule_expert.Data.t @ local @@ portable

Like wrap, but for once values.

Sourceval unwrap_once : access:'k Capsule_expert.Access.t -> ('a, 'k) Capsule_expert.Data.t @ local -> 'a @ local @@ portable

Like unwrap, but for once values.

Sourceval wrap_once_unique : access:'k Capsule_expert.Access.t -> 'a @ portable local -> ('a, 'k) Capsule_expert.Data.t @ portable local @@ portable

Like wrap, but for once unique values.

Sourceval unwrap_once_unique : access:'k Capsule_expert.Access.t -> ('a, 'k) Capsule_expert.Data.t @ portable local -> 'a @ portable local @@ portable

Like unwrap, but for once unique values.

Sourceval unwrap_shared : 'a 'k. access:'k Capsule_expert.Access.t @ local -> ('a, 'k) Capsule_expert.Data.t -> 'a @ local @@ portable

unwrap_shared ~access t returns the shared value of t, which lives in the capsule 'k. 'k is always the current capsule. Since 'a may have been shared with other threads, 'a must cross portability.

Sourceval create : (unit -> 'a) @ local local portable -> ('a, 'k) Capsule_expert.Data.t @@ portable

create f runs f within the capsule 'k and returns a pointer to the result of f.

Sourceval create_once : (unit -> 'a @ local) @ local local portable -> ('a, 'k) Capsule_expert.Data.t @ local @@ portable

Like create, but for once values.

Sourceval create_unique : (unit -> 'a @ portable) @ local local portable -> ('a, 'k) Capsule_expert.Data.t @ portable @@ portable

create_unique f runs f within the capsule 'k and returns a pointer to the result of f.

Sourceval map : password:'k Capsule_expert.Password.t @ local -> f:('a -> 'b) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> ('b, 'k) Capsule_expert.Data.t @@ portable

map ~password ~f t applies f to the value of p within the capsule 'k and returns a pointer to the result.

Sourceval both : ('a, 'k) Capsule_expert.Data.t -> ('b, 'k) Capsule_expert.Data.t -> ('a * 'b, 'k) Capsule_expert.Data.t @@ portable

both t1 t2 is a pointer to a pair of the values of t1 and t2.

Sourceval fst : ('a * 'b, 'k) Capsule_expert.Data.t -> ('a, 'k) Capsule_expert.Data.t @@ portable

fst t gives a pointer to the first value inside t

Sourceval snd : ('a * 'b, 'k) Capsule_expert.Data.t -> ('b, 'k) Capsule_expert.Data.t @@ portable

snd t gives a pointer to the second value inside t

Sourceval extract : password:'k Capsule_expert.Password.t @ local -> f:('a -> 'b @ portable local portable contended) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> 'b @ portable local portable contended @@ portable

extract ~password ~f t applies f to the value of t within the capsule 'k and returns the result. The result is within 'k so must be portable and is marked contended.

Sourceval inject : 'a 'k. 'a @ portable -> ('a, 'k) Capsule_expert.Data.t @@ portable

inject v creates a pointer to a value v injected into the capsule 'k. It's a specialization of create to values that are always uncontended.

Sourceval project : 'a 'k. ('a, 'k) Capsule_expert.Data.t -> 'a @ contended @@ portable

project t returns the value of t. The result is within 'k, so is marked contended. The value is required to always be portable, so unlike extract, project does not require permission to access 'k. This is safe because all accesses to the value happen only after it's marked contended.

Sourceval project_shared : 'a 'k. key:'k Capsule_expert.Key.t -> ('a, 'k) Capsule_expert.Data.t -> 'a @ local @@ portable

project_shared ~key t is like project t, but since t is a capsule associated with a key @ aliased global, the contents can be returned at shared.

Sourceval project_shared_unique : 'a 'k. key:'k Capsule_expert.Key.t -> ('a, 'k) Capsule_expert.Data.t @ portable -> 'a @ portable local @@ portable
Sourceval bind : password:'k Capsule_expert.Password.t @ local -> f:('a -> ('b, 'j) Capsule_expert.Data.t) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> ('b, 'j) Capsule_expert.Data.t @@ portable

bind ~password ~f t is project (map ~password ~f t).

Sourceval iter : password:'k Capsule_expert.Password.t @ local -> f:('a -> unit) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> unit @@ portable

iter is extract with result type specialized to unit.

Sourceval map_shared : 'a 'b 'k. password:'k Capsule_expert.Password.Shared.t @ local -> f:('a @ local -> 'b) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> ('b, 'k) Capsule_expert.Data.t @@ portable

map_shared ~password ~f t applies f to the shared parts of t within the capsule 'k and returns a pointer to the result. Since 'a may have been shared with other threads, 'a must cross portability.

Sourceval extract_shared : 'a 'b 'k. password:'k Capsule_expert.Password.Shared.t @ local -> f: ('a @ local -> 'b @ portable local portable contended) @ local local portable -> ('a, 'k) Capsule_expert.Data.t -> 'b @ portable local portable contended @@ portable

extract_shared ~password ~f t applies f to the shared parts of t within the capsule 'k and returns the result. The result is within 'k so must be portable and is marked contended. Since 'a may have been shared with other threads, 'a must cross portability.

Sourcemodule Shared : sig ... end
Sourcemodule Local : sig ... end

Functions to work with ('a, 'k) t @ local.

Sourcemodule Or_null : sig ... end