Module Capsule_prim.DataSource
Pointers to data within a capsule.
Pointers to data within a capsule.
('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.
wrap ~access v returns a pointer to the value v, which lives in the capsule 'k. 'k is always the current capsule.
unwrap ~access t returns the value of t, which lives in the capsule 'k. 'k is always the current capsule.
val wrap_unique :
access:'k Capsule_prim__.Prim.Access.t ->
'a @ unique ->
('a, 'k) t @ unique @@ portableLike wrap, but for unique values.
val unwrap_unique :
access:'k Capsule_prim__.Prim.Access.t ->
('a, 'k) t @ unique ->
'a @ unique @@ portableLike unwrap, but for unique values.
val wrap_once :
access:'k Capsule_prim__.Prim.Access.t ->
'a @ once ->
('a, 'k) t @ once @@ portableLike wrap, but for once values.
val unwrap_once :
access:'k Capsule_prim__.Prim.Access.t ->
('a, 'k) t @ once ->
'a @ once @@ portableLike unwrap, but for once values.
val wrap_once_unique :
access:'k Capsule_prim__.Prim.Access.t ->
'a @ unique once ->
('a, 'k) t @ unique once @@ portableLike wrap, but for once unique values.
val unwrap_once_unique :
access:'k Capsule_prim__.Prim.Access.t ->
('a, 'k) t @ unique once ->
'a @ unique once @@ portableLike unwrap, but for once unique values.
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.
create f runs f within the capsule 'k and returns a pointer to the result of f.
Like create, but for once values.
val create_unique :
(unit -> 'a @ unique) @ local once portable ->
('a, 'k) t @ unique @@ portablecreate_unique f runs f within the capsule 'k and returns a pointer to the result of f.
aliased t wraps the value inside an aliased Data.t in Modes.Aliased.t, making it cross aliased.
This is useful for if you need a Capsule.Data.t @ unique, but want the value it points to to be aliased.
val map :
password:'k Capsule_prim__.Prim.Password.t @ local ->
f:('a -> 'b) @ local once portable ->
('a, 'k) t ->
('b, 'k) t @@ portablemap ~password ~f t applies f to the value of p within the capsule 'k and returns a pointer to the result.
both t1 t2 is a pointer to a pair of the values of t1 and t2.
val both_unique :
('a, 'k) t @ unique ->
('b, 'k) t @ unique ->
('a * 'b, 'k) t @ unique @@ portableLike both, but for unique values
fst t gives a pointer to the first value inside t
snd t gives a pointer to the second value inside t
idx t i is a pointer to the value at i in t.
val extract :
password:'k Capsule_prim__.Prim.Password.t @ local ->
f:('a -> 'b @ unique once portable contended) @ local once portable ->
('a, 'k) t ->
'b @ unique once portable contended @@ portableextract ~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.
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.
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.
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.
val bind :
password:'k Capsule_prim__.Prim.Password.t @ local ->
f:('a -> ('b, 'j) t) @ local once portable ->
('a, 'k) t ->
('b, 'j) t @@ portablebind ~password ~f t is project (map ~password ~f t).
val iter :
password:'k Capsule_prim__.Prim.Password.t @ local ->
f:('a -> unit) @ local once portable ->
('a, 'k) t ->
unit @@ portableiter is extract with result type specialized to unit.
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.
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.
val unwrap_or_null :
('a Basement.Or_null_shim.Export.or_null, 'k) Or_null.t ->
('a, 'k) t Basement.Or_null_shim.Export.or_null @@ portable