CVS difference for ais/ai-10266.txt

Differences between 1.5 and version 1.6
Log of other versions for file ais/ai-10266.txt

--- ais/ai-10266.txt	2003/05/24 00:41:06	1.5
+++ ais/ai-10266.txt	2003/06/27 23:43:22	1.6
@@ -1,4 +1,4 @@
-!standard D.2.2 (5)                                03-03-03  AI95-00266-02/02
+!standard D.2.2 (5)                                03-06-05  AI95-00266-02/03
 !standard D.7 (00)
 !class amendment 01-06-01
 !status work item 01-06-01
@@ -15,7 +15,7 @@
 If a task terminates due to an unhandled exception, the exception occurrence
 is passed as a parameter to the procedure. The proposal provides an alternative
 to that of AI95-00266-01 which was rejected by IRTAW11; it responds to earlier
-comments by the the ARG. The proposal here introduces default procedures
+comments by the the ARG. The proposal here introduces default handlers,
 but does not go as far as task groups.
 
 !problem
@@ -40,39 +40,29 @@
   procedure Set_Normal_Termination_Handler(
                 New_Handler: in Protected_Termination_Handler;
                 Old_Handler: out Protected_Termination_Handler;
-                Id : in Task_Id := Current_Task);
+                Id : in Task_Id := Null_Task_Id);
               -- New_Handler is called immediately prior to task termination,
               -- if the task completed due to completing the last statement
               -- of the task body, or as part of waiting on a terminate
-              -- alternative.
+              -- alternative. If Task_Id = Null_Task_Id then a default
+	      -- handler is defined.
 
-  procedure Set_Default_Normal_Termination_Handler(
-                New_Handler: in Protected_Termination_Handler
-                Old_Handler: out Protected_Termination_Handler);
-
-
   procedure Set_Unhandled_Exception_Handler(
                 New_Handler: in Protected_Exceptional_Termination_Handler;
                 Old_Handler: out Protected_Termination_Handler;
-                Id : in Task_Id := Current_Task);
+                Id : in Task_Id := Null_Task_Id);
               -- New_Handler is called immediately prior to task termination,
               -- if the task completed due to an unhandled exception
-              -- during execution or activation
+              -- during execution or activation. If Task_Id = Null_Task_Id
+	      -- then a default handler is defined.
 
-  procedure Set_Default_Unhandled_Exception_Handler(
-                New_Handler: in Protected_Exceptional_Termination_Handler
-                Old_Handler: out Protected_Exceptional_Termination_Handler);
-
   procedure Set_Abnormal_Termination_Handler(
                 New_Handler: in Protected_Termination_Handler;
                 Old_Handler: out Protected_Termination_Handler;
-                Id : in Task_Id := Current_Task);
+                Id : in Task_Id := Null_Task_Id);
               -- New_Handler is called immediately prior to task termination,
-              -- if the task completed due to abortion.
-
-  procedure Set_Default_Abnormal_Termination_Handler(
-                New_Handler: in Protected_Termination_Handler
-                Old_Handler: out Protected_Termination_Handler);
+              -- if the task completed due to abortion.If Task_Id = Null_Task_Id
+	      -- then a default handler is defined.
 
 end Ada.Task_Termination;
 
@@ -114,7 +104,7 @@
 When any of the protected subprograms are set and the task
 has already terminated then the handler is executed immediately.
 
-If a null handler is set then this is equvalent to there being no
+If a null handler is set then this is equivalent to there being no
 handler.
 
 The requirement is that the user-supplied protected subprogram is usually
@@ -129,33 +119,6 @@
 It is a bounded error for the user-supplied protected subprogram to
 propagate an exception.
 
-An alternative model was considered whereby the following attributes were
-defined -- where T is a task type (after any implicit dereference):
-
-T'Unhandled_Exception_Handler
-T'Abnormal_Termination_Handler
-T'Normal_Termination_Handler
-T'Activation_Failure_Handler
-T'Termination_Without_Activation_Handler
-
-These would return subprograms similar to that defined above.
-They can be set via attribute_definition_clauses. This gives more
-functionality than the selected approach (in particular it allows failures
-before task activation to be handled). However, it has more impact on
-the language definition. The approach was rejected because a) of the
-language impact, b) the assumed target market here is a Ravenscar
-environment and failures before the tasks begin their execution would
-cause the program to fail, and c) the added functionality is of questionable
-use.
-
-Another drawback of the attribute approach is that it doesn't scale up to
-applications where tasks are allocated dynamically (at least not if the
-program needs to associate a different termination hook with different
-dynamically allocated tasks of the same task type).
-
-A pragma-based approach has the same set of issues as the attribute
-approach.
-
 !example
 
 The following example illustrates how the mechanisms can be used.
@@ -165,6 +128,7 @@
 fails due to being aborted.
 
 with Ada.Task_Identification; use Ada.Task_Identification;
+with Ada.Task_Termination; use Ada.Task_Termination;
 with Ada.Exceptions; use Ada.Exceptions;
 package Termination_Logging is -- library package
   protected Logger is
@@ -177,12 +141,15 @@
   end Logger;
 end Termination_Logging;
 
-
 package body Termination_Logging is
+
+  Old_Handler1 : Protected_Termination_Handler;
+  Old_Handler2 : Protected_Exceptional_Termination_Handler;
+
   protected body Logger is
     entry Guardian when Abort_Occurrence is
     begin
-      Abort_Occurence := False;
+      Abort_Occurrence := False;
     end Guardian;
     procedure Log_Non_Normal_Termination (
       Id: Task_Id; X: Exception_Occurrence) is
@@ -195,18 +162,20 @@
       Abort_Occurrence := True;
     end Note_Abnormal_Termination;
   end Logger;
-  Old_Exception_Handler : Protected_Exceptional_Termination_Handler;
-  Old_Abnormal_Handler : Protected_Termination_Handler;
-
 begin
-  Set_Default_Unhandled_Exception_Handler
-      (Logger.Log_Non_Normal_Termination'Access, Old_Exception_Handler);
-  Set_Default_Abnormal_Termination_Handler
-      (Logger.Note_Abnormal_Termination'Access, Old_Abnormal_Handler);
+  Set_Unhandled_Exception_Handler
+      (Logger.Log_Non_Normal_Termination'Access,Old_Handler2);
+  Set_Abnormal_Termination_Handler
+      (Logger.Note_Abnormal_Termination'Access,Old_Handler1);
+  -- Old_Handler1 and Old_Handler2 should both be null
 end Termination_Logging;
 
-!ACATS test
+!discussion
+
+Would it be useful to have a pragma to request the use of these
+facilities?
 
+!ACATS test
 
 !appendix
 

Questions? Ask the ACAA Technical Agent