RosettaCodeData/Task/Synchronous-concurrency/OCaml/synchronous-concurrency-2.ml
2024-10-16 18:07:41 -07:00

12 lines
405 B
OCaml

let reader count_source lines_dest =
let file = open_in "input.txt" in
let rec aux () =
let line = try Some (input_line file)
with End_of_file -> None in
sync (send lines_dest line);
match line with
| Some _ -> aux ()
| None -> let printed = sync (receive count_source) in
Printf.printf "The task wrote %i strings\n" printed;
close_in file
in aux ()