Skip to content
Snippets Groups Projects
Commit 1e9cf5b0 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[extlib] remove usleep, as sleepf introduced in 4.03.0 does the same thing

parent 4d07ce7b
No related branches found
No related tags found
No related merge requests found
......@@ -436,17 +436,12 @@ let temp_dir_cleanup_at_exit ?(debug=false) base =
in
try_dir_cleanup_at_exit 10 base
(* replace "noalloc" with [@@noalloc] for OCaml version >= 4.03.0 *)
[@@@ warning "-3"]
external usleep: int -> unit = "ml_usleep" "noalloc"
(* In ../utils/c_bindings.c ; man usleep for details. *)
(* ************************************************************************* *)
(** Strings *)
(* ************************************************************************* *)
external compare_strings: string -> string -> int -> bool = "compare_strings" "noalloc"
[@@@ warning "+3"]
external compare_strings: string -> string -> int -> bool =
"compare_strings" [@@noalloc]
let string_prefix ?(strict=false) prefix s =
let add = if strict then 1 else 0 in
......
......@@ -382,11 +382,6 @@ val safe_remove: string -> unit
val safe_remove_dir: string -> unit
val usleep: int -> unit
(** Unix function that sleep for [n] microseconds.
See [man usleep] for details.
Should not be used under Win32. *)
(* ************************************************************************* *)
(** Comparison functions *)
(* ************************************************************************* *)
......
......@@ -253,9 +253,3 @@ value single_precision_of_string(value str)
double d = f;
return caml_copy_double(d);
}
value ml_usleep(value v)
{
usleep( Int_val(v) );
return Val_unit ;
}
......@@ -259,7 +259,7 @@ let command ?(timeout=0) ?stdout ?stderr cmd args =
| Result r ->
res := r;
false
in while running () do Extlib.usleep 100000 (* 0.1s *) done ; !res
in while running () do Unix.sleepf 0.1 done ; !res
else
let f = command_generic ~async:false ?stdout ?stderr cmd args in
match f () with
......
......@@ -109,7 +109,8 @@ struct
let rec wait = function
| UNIT a -> a
| YIELD f -> Db.yield() ; wait (f Coin)
| WAIT(ms,f) -> Db.yield() ; Extlib.usleep ms ; wait (f Coin)
| WAIT(ms,f) ->
Db.yield() ; Unix.sleepf (float_of_int ms /. 1_000_000.); wait (f Coin)
let finished = function UNIT a -> Some a | YIELD _ | WAIT _ -> None
......@@ -341,7 +342,7 @@ let share sh = todo
let on_idle = ref
(fun f -> try
while f () do Extlib.usleep 50000 (* wait for 50ms *) done
while f () do Unix.sleepf 0.05 (* wait for 50ms *) done
with Db.Cancel -> ())
(* -------------------------------------------------------------------------- *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment