module Exchanger: sig .. end
Value exchangers.
type t
The type of exchangers, allowing two threads to swap values.
val make : unit -> t
Returns a new exchanger.
val exchange : t -> 'a -> 'a
Waits for another thread to arrive at the same exchange point, and
then swaps the values provided by the two threads.
Raises Runtime.Interrupted
if the thread is interrupted.
val exchange_time : t -> 'a -> int64 -> TimeUnit.t -> 'a
exchange_time e x t u
is similar to exchange e x
, except that the
current thread will at most wait for t
(time value whose unit is
u
).
Raises Runtime.Interrupted
if the thread is interrupted.
Raises Runtime.Timeout
if time has elapsed with no exchange.