jon.recoil.org

Module Data.SharedSource

Sourcetype ('a, 'k) data = ('a, 'k) Capsule_expert.Data.t
Sourcetype ('a, 'k) t

('a, 'k) t is the type of 'as in a "sub-capsule" of 'k that has a shared view of 'k and uncontended access to the sub-capsule enclosing 'a.

Both read and write operations only require 'k Access.t @ shared. However, unlike ('a, 'k) Data.t, ('a, 'k) Data.Shared.t does not cross contention.

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

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

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

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

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

A 'k Key.t @ global aliased indicates that all capsules have permanent read-only access to 'k. Therefore, ('a, 'k) t can be safely exposed.

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

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

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

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

Sourceval both : ('a, 'k) Capsule_expert.Data.Shared.t -> ('b, 'k) Capsule_expert.Data.Shared.t -> ('a * 'b, 'k) Capsule_expert.Data.Shared.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.Shared.t -> ('a, 'k) Capsule_expert.Data.Shared.t @@ portable

fst t gives a pointer to the first value inside t

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

snd t gives a pointer to the second value inside t

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

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

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

inject v is a pointer to an 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.Shared.t -> 'a @ contended @@ portable

project t returns the value of t. The result is within 'k, so must be portable and is marked contended. Since it's always portable, unlike with extract, we don't need exclusive access to 'k: all accesses to the value happen only after it's marked contended.

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

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

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

iter is extract with result type specialized to unit.

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

map_into is like Capsule.map_shared but returns a Shared.t.

Sourcemodule Local : sig ... end

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