| conditional_entry_call | timed_entry_call
select
select_alternative
{or
select_alternative}
[else
sequence_of_statements]
end select
;
select_alternative ::=
[when
condition =>]
selective_wait_alternative
| delay_alternative | terminate_alternative
terminate
;
when
and a condition, or if the condition is TRUE. It is said to be closed otherwise.
when
are evaluated in some order that is not defined by the language; open alternatives are thus determined. For an open delay alternative, the delay expression is also evaluated. Similarly, for an open accept alternative for an entry of a family, the entry index is also evaluated. Selection and execution of one open alternative, or of the else part, then completes the execution of the selective wait; the rules for this selection are described below.
select
accept
DRIVER_AWAKE_SIGNAL;
or
delay
30.0*SECONDS;
STOP_THE_TRAIN;
end select
;
task body
RESOURCE is
BUSY : BOOLEAN := FALSE;
begin
loop
select
when not
BUSY =>
accept
SEIZE do
BUSY := TRUE;
end
;
or
accept
RELEASE do
BUSY := FALSE;
end
;
or
terminate
;
end select
;
end loop
;
end
RESOURCE;
select
entry_call_statement
[sequence_of_statements]
else
sequence_of_statements
end select
;
procedure
SPIN(R : RESOURCE) is
begin
loop
select
R.SEIZE;
return
;
else
null
; -- busy waiting
end select
;
end loop
;
end
;
select
entry_call_statement
[sequence_of_statements]
or
delay_alternative
end select
;
select
CONTROLLER.REQUEST(MEDIUM)(SOME_ITEM);
or
delay
45.0;
-- controller too busy, try something else
end select
;