Commit c6332b03 authored by Guillaume Melquiond's avatar Guillaume Melquiond

Remove unused and non-portable function call_asynchronous.

parent 5567265b
......@@ -75,41 +75,6 @@ let open_temp_file ?(debug=false) filesuffix usefile =
close_out cout;
raise e
type 'a result =
| Result of 'a
| Exception of exn
open Unix
exception Bad_execution of process_status
let call_asynchronous (f : unit -> 'a) =
let cin,cout = pipe () in
let cin = in_channel_of_descr cin in
let cout = out_channel_of_descr cout in
match fork () with
| 0 ->
let result =
try
Result (f ())
with exn -> Exception exn in
Marshal.to_channel cout (result : 'a result) [];
close_out cout;
exit 0
| pid ->
let f () =
let result = (Marshal.from_channel cin: 'a result) in
close_in cin;
let _, ps = waitpid [] pid in
match ps with
| WEXITED 0 ->
begin match result with
| Result res -> res
| Exception exn -> raise exn
end
| _ -> raise (Bad_execution ps) in
f
let copy_file from to_ =
let cin = open_in from in
let cout = open_out to_ in
......
......@@ -41,19 +41,6 @@ val open_temp_file :
and call usefile on this file (filename and open_out).
usefile can close the file *)
val call_asynchronous : (unit -> 'a) -> (unit -> 'a)
(* Transform a synchronous call to an
asynchronous in a separate memory.
call_asynchronous f forks and run the
function in the child process. In the parent
process the function returned will wait the end
of the child process*)
(* With this function we can make fork in a thread
it is not as bad as it can be in 3.11.0 :
http://caml.inria.fr/mantis/view.php?id=4577
*)
val copy_file : string -> string -> unit
(** [copy_file from to] copy the file from [from] to [to] *)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment