Module Shared.LocalSource
Functions to work with ('a, 'k) t @ local.
val wrap :
access:'k Capsule_expert.Access.t @ local ->
'a @ local ->
('a, 'k) Capsule_expert.Data.Shared.t @ local @@ portablewrap ~access v returns a pointer to the local value v, which lives in the sub-capsule of 'k. 'k is always the current capsule.
val unwrap :
access:'k Capsule_expert.Access.t @ local ->
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
'a @ local @@ portableunwrap ~access t returns the value of t, which lives in the sub-capsule of 'k. 'k is always the current capsule.
val create :
(unit -> 'a @ local) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local @@ portablecreate f runs f within the sub-capsule of 'k and returns a local pointer to the result.
val map :
password:'k Capsule_expert.Password.Shared.t @ local ->
f:('a @ local -> 'b @ local) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
('b, 'k) Capsule_expert.Data.Shared.t @ local @@ portablemap ~pasword ~f t applies f to the value of p within the sub-capsule of 'k and returns a local pointer to the result.
val both :
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
('b, 'k) Capsule_expert.Data.Shared.t @ local ->
('a * 'b, 'k) Capsule_expert.Data.Shared.t @ local @@ portableboth t1 t2 is a pointer to a pair of the values of t1 and t2.
val fst :
('a * 'b, 'k) Capsule_expert.Data.Shared.t @ local ->
('a, 'k) Capsule_expert.Data.Shared.t @ local @@ portablefst t gives a pointer to the first value inside t
val snd :
('a * 'b, 'k) Capsule_expert.Data.Shared.t @ local ->
('b, 'k) Capsule_expert.Data.Shared.t @ local @@ portablesnd t gives a pointer to the second value inside t
val extract :
password:'k Capsule_expert.Password.Shared.t @ local ->
f:
('a @ local -> 'b @ local portable local portable contended) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
'b @ local portable local portable contended @@ portableextract ~pasword ~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.
val inject :
'a 'k. 'a @ local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local @@ portableinject 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.
val project :
'a 'k. ('a, 'k) Capsule_expert.Data.Shared.t @ local ->
'a @ local contended @@ portableproject 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.
val bind :
password:'k Capsule_expert.Password.Shared.t @ local ->
f:
('a @ local -> ('b, 'j) Capsule_expert.Data.Shared.t @ local) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
('b, 'j) Capsule_expert.Data.Shared.t @ local @@ portablebind ~password ~f t is project (map ~password ~f t).
val iter :
password:'k Capsule_expert.Password.Shared.t @ local ->
f:('a @ local -> unit) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.t @ local ->
unit @@ portableiter is extract with result type specialized to unit.
val map_into :
'a 'b 'k. password:'k Capsule_expert.Password.Shared.t @ local ->
f:('a @ local local -> 'b @ local) @ local local portable ->
('a, 'k) Capsule_expert.Data.Shared.data @ local ->
('b, 'k) Capsule_expert.Data.Shared.t @ local @@ portablemap_into is like Capsule.map_shared but returns a Shared.t.