small fixes in CCSemaphore

This commit is contained in:
Simon Cruanes 2016-01-25 14:26:30 +01:00
parent d3464563c1
commit 483f90cb52
2 changed files with 8 additions and 7 deletions

View file

@ -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

View file

@ -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