A task type is a limited type (see 7.4.4). Hence neither assignment nor the predefined comparison for equality and inequality are defined for objects of task types; moreover, the mode out is not allowed for a formal parameter whose type is a task type.
A task object is an object whose type is a task type. The value of a task object designates a task that has the entries of the corresponding task type, and whose execution is specified by the corresponding task body. If a task object is the object, or a subcomponent of the object, declared by an object declaration, then the value of the task object is defined by the elaboration of the object declaration. If a task object is the object, or a subcomponent of the object, created by the evaluation of an allocator, then the value of the task object is defined by the evaluation of the allocator. For all parameter modes, if an actual parameter designates a task, the associated formal parameter designates the same task; the same holds for a subcomponent of an actual parameter and the corresponding subcomponent of the associated formal parameter; finally, the same holds for generic parameters.
CONTROL : RESOURCE; TELETYPE : KEYBOARD_DRIVER; POOL : array(1 .. 10) of KEYBOARD_DRIVER; -- see also examples of declarations of single tasks in 9.1
Example of access type designating task objects:
type KEYBOARD is access KEYBOARD_DRIVER; TERMINAL : KEYBOARD := new KEYBOARD_DRIVER;
Since a task type is a limited type, it can appear as the definition of a limited private type in a private part, and as a generic actual parameter associated with a formal parameter whose type is a limited type. On the other hand, the type of a generic formal parameter of mode in must not be a limited type and hence cannot be a task type.
Task objects behave as constants (a task object always designates the same task) since their values are implicitly defined either at declaration or allocation, or by a parameter association, and since no assignment is available. However the reserved word constant is not allowed in the declaration of a task object since this would require an explicit initialization. A task object that is a formal parameter of mode in is a constant (as is any formal parameter of this mode).
If an application needs to store and exchange task identities, it can do so by defining an access type designating the corresponding task objects and by using access values for identification purposes (see above example). Assignment is available for such an access type as for any access type.
Subtype declarations are allowed for task types as for other types, but there are no constraints applicable to task types.
References: access type, actual parameter, allocator, assignment, component declaration, composite type, constant, constant declaration, constraint, designate, and 9.1, elaboration, entry, equality operator, formal parameter, formal parameter mode, generic actual parameter, generic association, generic formal parameter, generic formal parameter mode, generic unit, inequality operator, initialization, limited type, object, object declaration, parameter association, private part, private type, reserved word, subcomponent, subprogram, subtype declaration, task body, type.
Rationale references: 13.2.9 Task Types
Style Guide references: 6.1.1 Tasks, 6.1.2 Anonymous Task Types
Address any questions or comments to firstname.lastname@example.org.