jon.recoil.org

Module Capsule_expert.PasswordSource

Passwords represent permission to get access to a capsule.

Sourcetype 'k t

'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

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

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

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

Sourceval shared : 'k Capsule_expert.Password.t @ local -> 'k Capsule_expert.Password.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_expert.Access.t -> ('k Capsule_expert.Password.t @ local -> 'a @ local portable local) @ local local -> 'a @ local portable local @@ 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.