In Ada 2020 there is an attribute Non_Blocking
which explicitly marks the blocking/nonblocking attributes for static-analysis and the compiler ensuring things are correct.
But this doesn't help if you're stuck in Ada 2012 — and there are specific things that are "potentially blocking" like entry-calls and [IIRC] things like Ada.Text_IO.Put
— and SPARK takes the reasoning that if it's potentially blocking then you cannot ensure that it's not non-blocking.
According to the RM, here's what you have to look out for:
During a protected action, it is a bounded error to invoke an
operation that is potentially blocking. The following are defined to
be potentially blocking operations:
- a select_statement;
- an accept_statement;
- an entry_call_statement;
- a delay_statement;
- an abort_statement;
- task creation or activation;
- an external call on a protected subprogram (or an external requeue) with the same target object as that of the protected action;
- a call on a subprogram whose body contains a potentially blocking operation.
So, if the subprogram you're trying to call has a select
, accept
, delay
, or task
it's potentially blocking.