When a suspension is scheduled for execution, it gets inserted into a global priority list where it is waiting for execution. This global priority list is then processed explicitly by the wake/0 predicate. This separation of scheduling and execution enables the proper handling of priorities: Low priority suspensions are not necessarily executed by the next wake/0, but possibly later when the current priority has become low enough.
The separation also allows to schedule a batch of suspension lists together before entering the priority-based execution scheme.
wake/0 should therefore be called in the following situations: 1. after new suspensions have been scheduled by one or several calls to schedule_suspensions/1,2 or notify_constrained/1.
2. whenever the current priority was lowered, since that may allow further scheduled goals to be executed.
Note that wake/0 is implicitly invoked after every sequence of meta_unify handlers and should thus not be called inside the handlers.
[eclipse 4]: make_suspension(write(a), 1, S), schedule_suspensions(1, attr([S])), wake, write(b). ab S = 'SUSP-_280-dead' yes. [eclipse 5]: make_suspension(write(a), 1, S), schedule_suspensions(1, attr([S])), write(b), wake. ba S = 'SUSP-_280-dead' yes.