Button
Button

Reputation: 77

Ada: select then abort statement

I have a question regarding the "select then abort" language construct in Ada. The task I'm using looks something like:

select
  delay 1.0;
  do something with the partial result;
then abort
  loop 
    ...
    long calculation
    ...
    entry call to other task;
    ...
  end loop;
end select;

Can the code in the abort branch be aborted anywhere or only at certain points like delay statements or entry calls? In my program the code in the abort branch performs a long calculation and when aborted the partial calculated result is still useful. But if the code can be interrupted anywhere the problem of data inconsistencies arises.

Thank you

Upvotes: 3

Views: 3107

Answers (2)

egilhh
egilhh

Reputation: 6430

The abort can happen anywhere, except in an abort deferred region. A protected operation is an abort deferred region, so you can store your partial results inside a protected object.

Upvotes: 2

Anthony
Anthony

Reputation: 12407

Based on the information at adaic.org, the part in between then abort and end select can be aborted anywhere.

Upvotes: 1

Related Questions