RosettaCodeData/Task/Synchronous-concurrency/ALGOL-68/synchronous-concurrency.alg

33 lines
660 B
Text
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
(
STRING line;
INT count := 0, errno;
BOOL input complete := FALSE;
SEMA output throttle = LEVEL 0, input throttle = LEVEL 1;
2013-10-27 22:24:23 +00:00
2013-04-11 01:07:29 -07:00
FILE input txt;
errno := open(input txt, "input.txt", stand in channel);
2013-10-27 22:24:23 +00:00
2013-04-11 01:07:29 -07:00
PROC call back done = (REF FILE f) BOOL: ( input complete := TRUE );
on logical file end(input txt, call back done);
2013-10-27 22:24:23 +00:00
2013-04-11 01:07:29 -07:00
PAR (
WHILE
DOWN input throttle;
get(input txt,(line, new line));
UP output throttle;
NOT input complete
DO
count+:=1
OD
,
WHILE
DOWN output throttle;
NOT input complete
DO
print((line, new line));
UP input throttle
OD
);
print((count))
)