C.7.1 The Package Task_Identification
Static Semantics
The following language-defined
library package exists:
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 :
in 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;
private
... --
not specified by the language
end Ada.Task_Identification;
Dynamic Semantics
A value of the type Task_Id identifies an existent
task. The constant Null_Task_Id does not identify any task. Each object
of the type Task_Id is default initialized to the value of Null_Task_Id.
The function "=" returns True if and only
if Left and Right identify the same task or both have the value Null_Task_Id.
The function Image returns an implementation-defined
string that identifies T. If T equals Null_Task_Id, Image returns an
empty string.
The function Current_Task returns a value that identifies
the calling task.
The function Environment_Task returns a value that
identifies the environment task.
The effect of Abort_Task is the same as the
abort_statement
for the task identified by T. In addition, if T identifies the environment
task, the entire partition is aborted, see
E.1.
The functions Is_Terminated and Is_Callable return
the value of the corresponding attribute of the task identified by T.
The function Activation_Is_Complete returns True
if the task identified by T has completed its activation (whether successfully
or not). It returns False otherwise. If T identifies the environment
task, Activation_Is_Complete returns True after the elaboration of the
library_items
of the partition has completed.
For a
prefix
T that is of a task type (after any implicit dereference), the following
attribute is defined:
T'Identity
Yields a value of the type Task_Id
that identifies the task denoted by T.
E'Caller
Yields a value of the type Task_Id
that identifies the task whose call is now being serviced. Use of this
attribute is allowed only inside an
accept_statement,
or
entry_body
after the
entry_barrier,
corresponding to the
entry_declaration
denoted by E.
Program_Error is raised if a value of Null_Task_Id
is passed as a parameter to Abort_Task, Activation_Is_Complete, Is_Terminated,
and Is_Callable.
This paragraph was
deleted.
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.
Documentation Requirements
The implementation shall document the effect of calling
Current_Task from an entry body or interrupt handler.
NOTE 1 This package is intended for
use in writing user-defined task scheduling packages and constructing
server tasks. Current_Task can be used in conjunction with other operations
requiring a task as an argument such as Set_Priority (see
D.5).
NOTE 2 The function Current_Task
and the attribute Caller can return a Task_Id value that identifies the
environment task.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe