Parallel_capsule.With_rwlockSourceval with_write :
'a ('b : value_or_null). Parallel_kernel.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local -> ('a -> 'b @ portable contended) @ local once) @ local once portable unyielding ->
'b @ portable contendedwith_write parallel t ~f locks the reader-writer lock associated with t for writing and calls f on the protected value with access to parallel for doing parallel work, returning the result.
val with_write_or_cancel :
'a ('b : value_or_null). Parallel_kernel.t @ local ->
Await.Cancellation.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local -> ('a -> 'b @ portable contended) @ local once) @ local once portable unyielding ->
'b Await.Or_canceled.t @ portable contendedwith_write_or_cancel parallel c t ~f is Completed (with_write parallel t ~f) if c is not canceled, otherwise it is Canceled.
val with_scoped :
'a ('b : value_or_null). Parallel_kernel.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local ->
('a Await.Capsule.Scoped.t @ local ->
'b) @ local once) @ local once unyielding ->
'bwith_scoped t ~f locks the reader-writer lock associated with t for writing and calls f with a Scoped.t for the protected data, returning the result.
Since the provided callback does not have to be portable, this is useful when you need to acquire two mutexes for different capsules at the same time and move data between them. See With_mutex.with_scoped for an example.
val with_scoped_or_cancel :
'a ('b : value_or_null). Parallel_kernel.t @ local ->
Await.Cancellation.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local ->
('a Await.Capsule.Scoped.t @ local ->
'b) @ local once) @ local once unyielding ->
'b Await.Or_canceled.twith_scoped_or_cancel parallel c t ~f is Completed (with_scoped parallel t ~f) if c is not canceled, otherwise it is Canceled.
val with_read :
('a : value mod portable) ('b : value_or_null). Parallel_kernel.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local ->
('a @ shared ->
'b @ portable contended) @ local once) @ local once portable unyielding ->
'b @ portable contendedwith_read parallel t ~f locks the reader-writer lock associated with t for reading and calls f on the protected value with access to parallel for doing parallel work, returning the result.
val with_read_or_cancel :
('a : value mod portable) ('b : value_or_null). Parallel_kernel.t @ local ->
Await.Cancellation.t @ local ->
'a t ->
f:
(Parallel_kernel.t @ local ->
('a @ shared ->
'b @ portable contended) @ local once) @ local once portable unyielding ->
'b Await.Or_canceled.t @ portable contendedwith_read_or_cancel parallel c t ~f is Completed (with_read parallel t ~f) if c is not canceled, otherwise it is Canceled.
with_scoped_shared t ~f locks the reader-writer lock associated with t for reading and calls f with a Scoped.Shared.t for the protected data, returning the result.
with_scope_shared is similar to with_scoped, but hands out a Capsule.Scoped.Shared.t
with_scoped_shared_or_cancel parallel c t ~f is Completed (with_scoped_shared parallel t ~f) if c is not canceled, otherwise it is Canceled.