9.5.2 Entries and Accept Statements
Syntax
Name Resolution Rules
Legality Rules
An
entry_declaration
in a task declaration shall not contain a specification for an access
parameter (see
3.10).
if the
overriding_indicator
is
not overriding, then the entry shall not implement any inherited
subprogram.
In addition to the places where
Legality Rules normally apply (see
12.3),
these rules also apply in the private part of an instance of a generic
unit.
Static Semantics
In the
entry_body
for an entry family, the
entry_index_specification
declares a named constant whose subtype is the entry index subtype defined
by the corresponding
entry_declaration;
the value of the
named entry index identifies
which entry of the family was called.
Dynamic Semantics
The actions to be performed when an entry is called
are specified by the corresponding
accept_statements
(if any) for an entry of a task unit, and by the corresponding
entry_body
for an entry of a protected unit.
The interaction between a task
that calls an entry and an accepting task is called a
rendezvous.
For the execution of an
accept_statement,
the
entry_index,
if any, is first evaluated and converted to the entry index subtype;
this index value identifies which entry of the family is to be accepted.
Further execution
of the
accept_statement
is then blocked until a caller of the corresponding entry is selected
(see
9.5.3), whereupon the
handled_sequence_of_statements,
if any, of the
accept_statement
is executed, with the formal parameters associated with the corresponding
actual parameters of the selected entry call. Execution of the rendezvous
consists of the execution of the
handled_sequence_of_statements,
performance of any postcondition or type invariant checks associated
with the entry, and any initialization or finalization associated with
these checks, as described in
6.1.1 and
7.3.2.
After execution of the rendezvous, the
accept_statement
completes and is left. The two tasks then proceed independently. When
an exception is propagated from the
handled_sequence_of_statements
of an
accept_statement,
the same exception is also raised by the execution of the corresponding
entry_call_statement.
This paragraph was
deleted.
NOTE 1 A task entry has corresponding
accept_statements (zero or more), whereas a protected entry has a corresponding
entry_body (exactly one).
NOTE 4 The
condition
in the
entry_barrier
can reference anything visible except the formal parameters of the entry.
This includes the entry index (if any), the components (including discriminants)
of the protected object, the Count attribute of an entry of that protected
object, and data global to the protected unit.
The restriction against referencing the formal parameters
within an
entry_barrier
ensures that all calls of the same entry see the same barrier value.
If it is necessary to look at the parameters of an entry call before
deciding whether to handle it, the
entry_barrier
can be “
when True” and the caller can be requeued
(on some private entry) when its parameters indicate that it cannot be
handled immediately.
Examples
Examples of entry
declarations:
entry Read(V : out Item);
entry Seize;
entry Request(Level)(D : Item); -- a family of entries
Examples of accept
statements:
accept Shut_Down;
accept Read(V : out Item) do
V := Local_Item;
end Read;
accept Request(Low)(D : Item) do
...
end Request;
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe