jon.recoil.org

Module Extended.OwnedSource

Sourcetype 'a t : (value mod contended forkable many portable unyielding) with 'a @@ contended portable

A capsule that uses uniqueness tracking to enable different threads to gain uncontended access to its contents at different times without need for runtime synchronization.

Sourceval to_repr : 'a t @ unique -> 'a Isolated.Repr.t @ unique
Sourceval of_repr : 'a Isolated.Repr.t @ unique -> 'a t @ unique
Sourceval create : (unit -> 'a @ unique) @ local once portable -> 'a t @ unique

create f runs f within a fresh capsule, and creates a Capsule.Owned.t containing the result.

Sourceval freeze : ('a : value mod portable). 'a t -> 'a Frozen.t

freeze t takes an aliased owned capsule (which can no longer be written to since it isn't unique) and converts it to a Frozen.t.

Sourceval unwrap : 'a t @ unique -> 'a @ unique

unwrap t consumes a unique isolated capsule t and returns the underlying value, merging the capsule with the current capsule.

Sourceval get_contended : ('a : value mod aliased portable). 'a t @ unique -> #('a t * 'a) @ unique contended

Project out a contended reference to the underlying value from a unique t, returning the unique t back alongside the alias to the underlying value.

Sourceval with_ : ('a : value mod aliased) ('b : value mod contended portable). 'a t @ unique -> f:('a -> 'b @ unique) @ local once portable -> #('a t * 'b) @ unique

with_ t ~f takes a unique isolated capsule t, calls f with its value, and returns a tuple of the unique isolated capsule and the result of f.