[ library(timeout) | Reference Manual | Alphabetic Index ]

call_timeout_safe(+Goal)

Execute Goal, deferring the execution of an interrupting timeout predicate TimeOutGoal until Goal completes.
Goal
Goal to execute

Description

Metacall Goal, ensuring that its execution is not interrupted and preemptively aborted by a timeout of the timeout/3 or timeout/7 predicate. If a timeout would have occurred during the execution of Goal, it is effectively deferred until Goal completes.

The predicate can be used within a computation which is subject to timeouts, to ensure that subgoals which should be executed as an atomic sequence preserve this atomicity at the cost of delaying the execution of TimeOutGoal.

In all other respects the semantics of call_timeout_safe/1 is the same as call/1.

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Resatisfiable

If Goal is resatisfiable.

Examples

    ?- timeout(call_timeout_safe((writeln('Goal started'), 
                               sleep(5), 
                               writeln('Goal completed'))),
            3, writeln('Timeout expired!')).
    Goal started
    Goal completed
    Timeout expired!
    Yes (0.01s cpu)
    

See Also

timeout / 3, timeout / 7