[ ECLiPSe Control built-in.|Group Index| Full Index]

schedule_suspensions(+Position, +Attribute)

Take the suspension list on argument position Position within Attribute, and schedule them for execution.

+Position
Integer indicating the position of the suspension list.
+Attribute
Compound term, typically a variable's attribute with a suspension list in Position'th argument.

Description

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

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.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Position or Attribute is not instatiated.
(5) Type error
Position is not an integer.
(5) Type error
Attribute is not a structure or it Position'th argument is not a list of suspensions.
(6) Range error
Attribute does not have a Position'th argument.

Examples


[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 = 'WOKEN GOAL'
T = 'WOKEN GOAL'
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 = 'GOAL'(d, eclipse)
T = 'WOKEN GOAL'
Attr = attr(['GOAL'(d, eclipse)])

Delayed goals:
        d
yes.


See Also

demon / 1, insert_suspension / 3, insert_suspension / 4, make_suspension / 3, suspension_to_goal / 3, wake / 0