module Semaphore:sig
..end
type
t
val make : int32 -> bool -> t
make p f
returns a new semaphore with p
permits, f
indicating
whether a fair ordering policy is requested.
p
can be negative, meaning that permits should be released before
any acquisition.
val acquire : t -> int32 -> unit
acquire s p
acquires p
permits from semaphore s
, blocking until
they are available.
Raises Invalid_argument
if p
is negative.
Raises Runtime.Interrupted
if the thread is interrupted.
val acquire_uninterruptibly : t -> int32 -> unit
acquire_uninterruptibly s p
is similar to acquire s p
, except
that waiting thread cannot be interrupted.
Raises Invalid_argument
if p
is negative.
val available_permits : t -> int32
val drain_permits : t -> int32
val get_queue_length : t -> int32
val has_queued_threads : t -> bool
val is_fair : t -> bool
val release : t -> int32 -> unit
release s p
releases p
permits from semaphore s
.
Raises Invalid_argument
if p
is negative.
val try_acquire : t -> int32 -> bool
try_acquire s p
is similar to acquire s p
, except the function
always returns immediately returning true
if acquisition was
successful.
Raises Invalid_argument
if p
is negative.
val try_acquire_time : t -> int32 -> int64 -> TimeUnit.t -> bool
try_acquire_time s p t u
is similar to try_acquire s p
, except
that the current thread will at most wait for t
(time value whose
unit is u
).
Raises Invalid_argument
if p
is negative.
Raises Runtime.Interrupted
if the thread is interrupted.