ADA:Tick

Z Wiki Rafał (ert16) Trójniak

Spis treści

Opis działania

Pogram wyświetla komunikat w pętli

Kod

count.adb

with ada.real_time,Ada.Text_IO,Ada.Integer_Text_IO;
use  ada.real_time,Ada.Text_IO,Ada.Integer_Text_IO;
package body count is
	task body Counter is
		DDL : Ada.Real_Time.Time;
		Period:constant Ada.Real_Time.Time_Span := 
			Ada.Real_Time.Microseconds(Interval);
	begin
		DDL := Ada.Real_Time.Clock;
		loop
			put ("Tick");	 new_line;
			DDL:=DDL + Period;
			delay until DDL;
		end loop;
	end;
end count;

count.ads

with system; use system;
package count is
	task type Counter(Pri:System.Priority := 0;
		Interval:Positive := 100)is
		pragma Priority(Pri);
	end;
end count;

main.adb

with count;
use count;
 
procedure main IS 
	a: count.Counter(0,1000*1000) ;
begin
	null;
end;
Osobiste