jon.recoil.org

Module Data.Or_nullSource

Sourcetype (('a : value_or_null), 'k) t
Sourceval wrap : ('a : value_or_null) 'k. access:'k Capsule_expert.Access.t -> 'a -> ('a, 'k) Capsule_expert.Data.Or_null.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 : ('a : value_or_null) 'k. access:'k Capsule_expert.Access.t -> ('a, 'k) Capsule_expert.Data.Or_null.t -> 'a @@ portable

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

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

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

Sourceval project : 'a 'k. ('a, 'k) Capsule_expert.Data.Or_null.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.