with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Exceptions; use Exceptions;
pragma Elaborate_All (Exceptions);
package body Scoped_Tasks is
Start_Up_Time : constant Time := Clock;
No_of_Iterations : constant Positive := 3;
Delay_Per_Iteration : constant Duration := 1.5;
subtype Repeat_for is Positive range 1 .. No_of_Iterations;
task body Scoped_Task is
Id : Colours;
begin
accept Hand_over_Task_Id (Set_Id : Colours) do
Id := Set_Id;
end Hand_over_Task_Id;
if Id = Blue then
raise Scoped_Task_is_not_too_well;
end if;
for I in Repeat_for loop
Put_Line ("Task " & Colours'Image (Id) & " at" & Duration'Image (Clock - Start_Up_Time) & " seconds since start up");
delay Delay_Per_Iteration;
end loop;
exception
when X_Id : others => Show_Exception (X_Id);
end Scoped_Task;
end Scoped_Tasks;