Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
open Event

View file

@ -0,0 +1,12 @@
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 ()

View file

@ -0,0 +1,6 @@
let printer lines_source count_target =
let rec aux i =
match sync (receive lines_source) with
| Some line -> print_endline line; aux ( i + 1 )
| None -> sync (send count_target i)
in aux 0

View file

@ -0,0 +1,6 @@
let _ =
let count = new_channel ()
and lines = new_channel ()
in
let _ = Thread.create (printer lines) count
in reader count lines