with Ada.Exceptions; use Ada.Exceptions;
with Ada.Task_Termination; use Ada.Task_Termination;
with Ada.Text_IO; use Ada.Text_IO;
package body Scoped_Tasks_Finalizer is
protected body Finalizer is
procedure Last_Wish (Cause : Cause_Of_Termination;
Id : Task_Id;
X : Exception_Occurrence) is
begin
case Cause is
when Normal => Put_Line ("Task " & Image (Id) & " came to a peaceful end.");
when Abnormal => Put_Line ("Somethings really nasty happend to task " & Image (Id));
when Unhandled_Exception => Put_Line ("Unhandled exception " & Exception_Name (X) & " in task " & Image (Id));
end case;
end Last_Wish;
procedure Register (Id : Task_Id) is
begin
Set_Specific_Handler (T => Id, Handler => Last_Wish'Access);
end Register;
end Finalizer;
end Scoped_Tasks_Finalizer;