[ Advanced Control and Suspensions | Reference Manual | Alphabetic Index ]

wake

Execute all scheduled suspensions whose priorities are higher than the current one.

Description

Suspensions in ECLiPSe go through several stages: They are created, attached to variables or symbolic triggers, later scheduled for execution, and finally executed.

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. It will execute, in order of priority, all scheduled suspensions that have priority higher than the current execution priority. The woken goals themselves will be executed under their specific run_priority, which may be higher than their scheduling priority. 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.

Fail Conditions

Fails if a woken goal fails

Resatisfiable

Resatisfiable if a woken goal is resatisfiable

Examples

[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.

See Also

make_suspension / 3, insert_suspension / 3, suspend / 3, suspend / 4, schedule_suspensions / 1, schedule_suspensions / 2, attach_suspensions / 2