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

set_suspension_data(+Susp, +Name, +Value)

Modify properties of suspended goals.
Susp
A suspension or variable.
Name
An atom.
Value
An integer.

Description

This built-in is used to modify fields of the abstract suspension data type. The modifiable properties of a suspension are:

Name        Type        Value
-------------------------------------------------------------
priority    Integer     Waking priority
invoc       Integer     Invocation number (debugging)
All modifications are undone on backtracking. Changes to the priority only have an effect the next time the suspension is scheduled (ie changing the priority of an already scheduled suspension has no effect unless it is a demon which can become suspended again). If Susp is a variable or a dead suspension, this predicate silently succeeds, doing nothing.

Note that a suspension is not a standard logical data structure and can only be manipulated in a restricted way. In particular, a suspension cannot be printed (e.g. using writeq/1,2) and then read back, giving a term identical to the one that was printed.

Modes and Determinism

Exceptions

(4) instantiation fault
Name or Value is not instantiated.
(5) type error
Susp is instantiated, but not a suspension.
(5) type error
Name is instantiated but not an atom.
(6) out of range
Name is not the name of a modifiable suspension property.

Examples

    [eclipse 1]: make_suspension(writeln(hello),5,S),
	    set_suspension_data(S, priority, 2),
	    get_suspension_data(S, priority, P).

    S = 'SUSP-_123-susp'
    P = 2
    Delayed goals:
	    writeln(hello)
    yes.


    :- demon d/2.
    d(X, Susp) :-
        ( var(S) ->        % initial suspend
	    suspend(d(X, Susp), 5, X->constrained, Susp)
	; finished(X) ->   % terminate
	    kill_suspension(Susp)
	; useful(X) ->     % raise priority
	    set_suspension_data(Susp, priority, 4)
	;                  % lower priority
	    set_suspension_data(Susp, priority, 6)
	).




See Also

delayed_goals / 1, kill_suspension / 1, make_suspension / 3, get_suspension_data / 3, get_priority / 1, call_priority / 2, suspend / 3, suspensions / 1, current_suspension / 1, get_suspension_data / 3