timeout package, which may be loaded by the query
| ?- use_module(library(timeout)).
contains the predicate:
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 NT/2000/XP, as of SICStus 3.10, thread virtual time is used, which is the same as process virtual time for single-threaded processes. Under Windows 98/ME the time is measured in real time (wall time), due to limitations in those operating systems.
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).
time_out/3 is implemented by raising and handling
time_out exceptions, so any exception handler in the scope of
Goal must be prepared to pass on
The following incorrect example shows what can happen otherwise:
| ?- time_out(on_exception(Q,(repeat,false),true), 1000, Res). Q = time_out, Res = success