jon.recoil.org

Module Capsule_prim.PasswordSource

Passwords represent permission to get access to a capsule.

Passwords represent permission to get access to a capsule.

Sourcetype 'k t : void mod contended external_ portable unyielding

'k t is the type of "passwords" representing permission for the current thread to have uncontended access to the capsule 'k. They are only ever available locally, so cannot move between threads.

Obtaining a 'k t requires exclusive access to 'k, either through a 'k Key.t @ unique or indirectly through acquiring a mutex or rw-lock associated with 'k. The mode system prevents retaining the 'k t after releasing access to the capsule. This guarantees that uncontended access to the capsule is only granted to one thread at a time.

Sourcetype 'k boxed : value mod contended external_ portable unyielding

A boxed version of Password.t for places where you need a type with layout value.

Sourceval box : 'k t @ local -> 'k boxed @ local @@ portable
Sourceval unbox : 'k boxed @ local -> 'k t @ local @@ portable
Sourcemodule Shared : sig ... end

Shared passwords represent permission to get shared access to a capsule.

Sourceval shared : 'k t @ local -> 'k Shared.t @ local @@ portable

shared t downgrades a 'k password to a 'k shared password.

Sourceval with_current : ('a : value_or_null) 'k. 'k Capsule_prim__.Prim.Access.t -> ('k t @ local -> 'a @ unique once) @ local once -> 'a @ unique once @@ portable

with_current k f calls f with a password for the current capsule k.

Note f cannot return the unforkable password, as the result is forkable.