mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
small fixes in CCSemaphore
This commit is contained in:
parent
d3464563c1
commit
483f90cb52
2 changed files with 8 additions and 7 deletions
|
|
@ -6,11 +6,12 @@ type t = {
|
|||
cond : Condition.t;
|
||||
}
|
||||
|
||||
let create n = {
|
||||
n;
|
||||
mutex=Mutex.create();
|
||||
cond=Condition.create();
|
||||
}
|
||||
let create n =
|
||||
if n <= 0 then invalid_arg "Semaphore.create";
|
||||
{ n;
|
||||
mutex=Mutex.create();
|
||||
cond=Condition.create();
|
||||
}
|
||||
|
||||
let get t = t.n
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ type t
|
|||
|
||||
val create : int -> t
|
||||
(** [create n] creates a semaphore with initial value [n]
|
||||
@raise Invalid_argument if [n < 0] *)
|
||||
@raise Invalid_argument if [n <= 0] *)
|
||||
|
||||
val get : t -> int
|
||||
(** Current value *)
|
||||
|
||||
val acquire : int -> t -> unit
|
||||
(** [acquire n s] blocks until [get s > n], then atomically
|
||||
(** [acquire n s] blocks until [get s >= n], then atomically
|
||||
sets [s := !s - n] *)
|
||||
|
||||
val release : int -> t -> unit
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue