Module Await_kernel.SyncSource

Abstract implementation of bounded awaiting.

Operations which might need to synchronize with other threads for a bounded amount of time, eg to acquire a lock, take a Sync.t which provides an implementation of synchronization for them to use.

Usually, you should use the Sync.t provided by a parallelism or concurrency scheduler, but if you don't have one available you can use Sync_blocking.sync instead.

Sourcetype t : value mod contended non_float portable

Represents the capability to block for a bounded amount of time.

Sourceval with_ : 'c ('r : value_or_null). yield:('c @ local -> Base.unit) Base.or_null @ local -> sync:(#('c * Trigger.t Base.global) @ local -> Base.unit) @ local -> 'c @ local -> f:(t @ local -> 'r @ local unique once forkable) @ local once -> 'r @ local unique once forkable @@ portable

with_ ~yield ~sync ctx ~f calls f with an implementation of synchronization such that sync ctx t trigger is its implementation of sync, and yield ctx t is its implementation of yield.

Sourceval create : yield:('c @ local portable contended -> Base.unit) Base.or_null @ portable -> sync: (#('c Base.portended * Trigger.t Base.global) @ local -> Base.unit) @ portable -> 'c @ portable contended -> t @@ portable

create ~yield ~sync ctx is a new implementation of synchronization such that sync ctx t trigger is its implementation of sync, and yield ctx t is its implementation of yield.

Sourceval yield : t @ local -> Base.unit @@ portable

yield t uses t to yield to the scheduler using the implementation of yielding associated with t.

Sourcemodule For_testing : sig ... end