Tasks#
Asynchronous Task Control#
This subclause introduces a language-defined package to do asynchronous suspend/resume on tasks. It uses a conceptual held priority value to represent the task’s held state.
with Ada.Task_Identification;
package Ada.Asynchronous_Task_Control
with Preelaborate, Nonblocking, Global => in out synchronized is
procedure Hold (T: Ada.Task_Identification.Task_Id);
procedure Continue(T: Ada.Task_Identification.Task_Id);
function Is_Held (T: Ada.Task_Identification.Task_Id) return Boolean;
end Ada.Asynchronous_Task_Control;
Erroneous Execution
If any operation in this package is called with a parameter T
that specifies a task object that no longer
exists, the execution of the program is erroneous.
Task Identification#
package Ada.Task_Identification
with Preelaborate, Nonblocking, Global => in out synchronized is
type Task_Id is private with Preelaborable_Initialization;
Null_Task_Id: constant Task_Id;
function "="(Left, Right: Task_Id) return Boolean;
function Image(T: Task_Id) return String;
function Current_Task return Task_Id;
function Environment_Task return Task_Id;
procedure Abort_Task(T: Task_Id)
with Nonblocking => False;
function Is_Terminated (T: Task_Id) return Boolean;
function Is_Callable (T: Task_Id) return Boolean;
function Activation_Is_Complete(T: Task_Id) return Boolean;
end Ada.Task_Identification;
Bounded (Run-Time) Errors
It is a bounded error to call the Current_Task
function from an entry_body, interrupt handler, or
finalization of a task attribute. Program_Error
is raised, or an implementation-defined value of the type
Task_Id
is returned.
Erroneous Execution
If a value of Task_Id
is passed as a parameter to any of the operations declared in this package (or any
language-defined child of this package), and the corresponding task object no longer exists, the execution of the
program is erroneous.
Task Attributes#
with Ada.Task_Identification; use Ada.Task_Identification;
generic
type Attribute is private;
Initial_Value: Attribute;
package Ada.Task_Attributes
with Nonblocking, Global => in out synchronized is
type Attribute_Handle is access all Attribute;
function Value (T: Task_Id := Current_Task) return Attribute;
function Reference(T: Task_Id := Current_Task) return Attribute_Handle;
procedure Set_Value (Val: Attribute; T: Task_Id := Current_Task);
procedure Reinitialize( T: Task_Id := Current_Task);
end Ada.Task_Attributes;
Bounded (Run-Time) Errors
If the package Ada.Task_Attributes
is instantiated with a controlled type and the controlled type has
user-defined Adjust
or Finalize
operations that in turn access task attributes by any of the above
operations, then a call of Set_Value
of the instantiated package constitutes a bounded error. The call may
perform as expected or may result in forever blocking the calling task and subsequently some or all tasks of the
partition.
Erroneous Execution
It is erroneous to dereference the access value returned by a given call on Reference
after a subsequent
call on Reinitialize
for the same task attribute, or after the associated task terminates.
If a value of Task_Id
is passed as a parameter to any of the operations declared in this package and the
corresponding task object no longer exists, the execution of the program is erroneous.
An access to a task attribute via a value of type Attribute_Handle
is erroneous if executed concurrently
with another such access or a call of any of the operations declared in package Task_Attributes
. An access
to a task attribute is erroneous if executed concurrently with or after the finalization of the task attribute.
Task Termination#
with Ada.Task_Identification;
with Ada.Exceptions;
package Ada.Task_Termination
with Preelaborate, Nonblocking, Global => in out synchronized is
type Cause_Of_Termination is (Normal, Abnormal, Unhandled_Exception);
type Termination_Handler is access protected procedure(Cause: Cause_Of_Termination;
T : Ada.Task_Identification.Task_Id;
X : Ada.Exceptions.Exception_Occurrence);
function Current_Task_Fallback_Handler return Termination_Handler;
function Specific_Handler(T: Ada.Task_Identification.Task_Id) return Termination_Handler;
procedure Set_Dependents_Fallback_Handler( Handler: Termination_Handler);
procedure Set_Specific_Handler(T: Ada.Task_Identification.Task_Id; Handler: Termination_Handler);
end Ada.Task_Termination;
Erroneous Execution
For a call of Set_Specific_Handler
or Specific_Handler
, if the task identified by T
no
longer exists, the execution of the program is erroneous.