Module Capsule_expert.KeySource
Keys represent the ownership of the capsule.
'k t @ unique represents the exclusive ownership of the capsule 'k. The uniqueness of 'k t guarantees that only one thread can access the capsule at a time.
Obtaining a unique 'k t requires either calling Capsule.create or acquiring a synchronization primitive associated with 'k. Such primitives are provided by the Await library.
'k t @ aliased indicates that the key has been permanently shared, since it's avaiable aliased and therefore not available uniquely. Therefore, we can allow all threads read access to 'k.
A boxed version of Key.t for places where you need a type with layout value.
val box :
'k Capsule_expert.Key.t @ portable ->
'k Capsule_expert.Key.boxed @ portable @@ portableval unbox :
'k Capsule_expert.Key.boxed @ portable ->
'k Capsule_expert.Key.t @ portable @@ portableval with_password :
('a : value_or_null) 'k. 'k Capsule_expert.Key.t @ portable ->
f:('k Capsule_expert.Password.t @ local -> 'a @ portable) @ local local ->
#('a * 'k Capsule_expert.Key.t) @ portable @@ portablewith_password k ~f runs f, providing it a password for 'k, and returns the result of f together with the key.
If f raises an exception, the key is destroyed, leaking the contents of the capsule.
val with_password_local :
('a : value_or_null) 'k. 'k Capsule_expert.Key.t @ portable ->
f:('k Capsule_expert.Password.t @ local -> 'a @ local) @ local local ->
'a @ local @@ portablewith_password_local k ~f runs f, providing it a password for 'k, and returns the result of f. The key is destroyed, but the local password can be returned to provide access to the capsule.
with_password_shared k ~f runs f, providing it a shared password for 'k, and returns the result of f.
As with_password_shared, but returns a local value.
val access :
('a : value_or_null) 'k. 'k Capsule_expert.Key.t @ portable ->
f:
('k Capsule_expert.Access.t -> 'a @ portable local portable contended) @ local local portable ->
#('a * 'k Capsule_expert.Key.t) @ portable local portable contended @@ portableaccess k ~f runs f, providing it access to the capsule 'k, and returns the result of f together with the key.
If f raises an exception, the key is destroyed, leaking the contents of the capsule, and the exception is reraised.
val access_local :
('a : value_or_null) 'k. 'k Capsule_expert.Key.t @ portable ->
f:
('k Capsule_expert.Access.t ->
'a @ local portable local portable contended) @ local local portable ->
#('a * 'k Capsule_expert.Key.t) @ local portable local portable contended @@ portableAs access, but local.
access_shared k ~f runs f, providing it a shared access to 'k, and returns the result of f. Exceptions raised from f are re-raised.
As access_shared, but returns a local value.
val globalize_unique :
'k Capsule_expert.Key.t @ local portable ->
'k Capsule_expert.Key.t @ portable @@ portableglobalize_unique k promotes a local unique key to a global one.
val destroy :
'k Capsule_expert.Key.t @ local portable ->
'k Capsule_expert.Access.t @@ portabledestroy k returns 'k Access.t for 'k, merging it with the current capsule. The key is destroyed.
unsafe_mk () unsafely makes a unique key for an arbitrary capsule.