11.1.1 How it works
Subroutine Suspendible declares a subprogram that can suspend: stop running for a moment while it waits for another task, a channel or a host effect. The main algorithm is suspendible without being marked.
Every call to a suspendible unit must be preceded by Await. That way, reading the code, you see exactly where the program can pause: nowhere else.
Await, pauses while another one works and continues with the result. Outside the marked points it is never interrupted.Two timelines. Task A works, pauses at Await while task B works, and continues when B hands it the result.
ProgramA suspendible call without Await
Subroutine Suspendable Doble(n As Integer) As Integer
Return n * 2;
EndSubroutine
Algorithm SinAguardar
Write Doble(2);
EndAlgorithmDiagnostics
suspendibleCallWithoutAwait· error · 6:9 · A call to a suspendable subprogram must use await
The program finishes with an error.
Await can go in any position of an expression. What was computed before the wait is kept.
In short
Suspendibledeclares a unit that can pause.- Every pause point is marked with
Await. - Between two
Awaits, a task is not interrupted.