Reputation: 29
I am an absolute beginner with Ada, and there's one thing I cannot find a concrete definition for - that's the statement entry
.
I understand an entry with a barrier - if the barrier is true, the statement can execute and if false, the task is queued until it's evaluated to be true.
For example:
entry Get(Item : out Data_Item) when Number_In_Buffer /= 0 is
begin
...
end Get;
But what does it mean for the statement entry
to appear without a following when
statement?
Upvotes: 1
Views: 3097
Reputation: 25501
ARM9.4 describes protected objects, which is where entry bodies (as in your code) occur.
It’s not clear from your question, but I think you’re describing a protected specification, with an entry declaration.
protected type Resource is
entry Seize;
procedure Release;
private
Busy : Boolean := False;
end Resource;
protected body Resource is
entry Seize when not Busy is
begin
Busy := True;
end Seize;
procedure Release is
begin
Busy := False;
end Release;
end Resource;
It is not the caller’s business how the entry is guarded, just that it is. One thing that’s caught me out a couple of times is that an entry body must have a guard; there are some circumstances (requeueing - search the Ada 95 Rationale II.9 for protected Event
) where when True
is OK.
Upvotes: 4
Reputation: 6158
An ENTRY is also a connection point for TASK communication. In the TASK definition, it is ENTRY. In the TASK BODY, it is an ACCEPT statement. So every ENTRY in a TASK definition has a corresponding ACCEPT in the TASK body.
Upvotes: 0