Sleep Test 2

program sleeptest2;
(* illustrates timeout alternative to select *)

var
	coms: channel of synchronous;

process q;
var
	off: boolean;

begin
	off := false;
	repeat
		select
			coms ? any;
			writeln('received');
		or
			timeout 5;
			off := true;
			writeln('timed out')
		end
	until off
end;

process p;
var
	count: integer;
begin
	count := 0;
	repeat
		sleep(3);
		count := count + 1;
		write('sent ');
		coms ! any
	until count = 10;
end;

begin
	cobegin
		q; p
	coend
end.

...



Última actualización: 23 de febrero de 2004
abia@dlsi.ua.es