The task of schedule_suspensions/2 is to take suspensions from a suspension list and schedule them for execution. The suspensions are put into a global priority list, according to their individual priority. A subsequent wake/0 will then actually execute them.
As a side effect, the suspension list within Attribute is updated, ie. suspensions which are no longer useful are removed destructively.
[eclipse 1]: make_suspension(writeln(hello), 4, S),
make_suspension(writeln('hi there'), 2, T),
Attr = attr([S,T]),
schedule_suspensions(1, Attr),
wake.
hi there
hello
S = 'SUSP-_306-dead'
T = 'SUSP-_311-dead'
Attr = attr([])
yes.
[eclipse 2]: [user].
:- demon(d/0).
d :- writeln(demon).
user compiled traceable 68 bytes in 0.12 seconds
yes.
[eclipse 3]: make_suspension(d, 4, S),
make_suspension(writeln('hi there'), 2, T),
Attr = attr([S,T]),
schedule_suspensions(1,Attr),
wake.
hi there
demon
S = 'SUSP-_304-susp'
T = 'SUSP-_309-dead'
Attr = attr(['SUSP-_304-susp'])
Delayed goals:
d
yes.