Next: , Previous: lib-terms, Up: The Prolog Library

10.39 Meta-Call with Limit on Execution Time—library(timeout)

Exported predicates:

time_out(:Goal, +Time, -Result)
The Goal is executed as if by call/1. If computing any solution takes more than Time milliseconds, the goal will be aborted and Result unified with the atom time_out. If the goal succeeds within the specified time, Result is unified with the atom success. Time must be a number between (not including) 0 and 2147483647.

The time is measured in process virtual time under UNIX. Under Windows, thread virtual time is used, which is the same as process virtual time for single-threaded processes.

The precision of the time out interval is usually not better than several tens of milliseconds. This is due to limitations in the timing mechanisms used to implement library(timeout).

This library can only be used by one SICStus instance in a process, which is the usual way to run SICStus. This limitation only affects programs that load SICStus from C or Java and run more than one SICStus instance in the same process.

time_out/3 is implemented by raising and handling time_out exceptions but, as of SICStus Prolog 4.1.3, these exceptions will not be intercepted by the normal exception handlers (on_exception/3 and catch/3).

Send feedback on this subject.