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

This module contains utilities for computing a goal with limit on execution time.

As of release 4.4, this library no longer uses a foreign resource, and it can be used by more than one SICStus instance in the same process.

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, as if by throw/1, 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 positive integer, less than 2147483647.

Currently, time is measured in runtime (as opposed to walltime), i.e. the time does not increment while the program is waiting, e.g. during a blocking read.

Ideally, the measured runtime should be thread-specific, i.e. it should not be affected by computations done in other threads in the process (of course, thread-specific time is the same as process runtime for a single-threaded process). Thread-specific runtime measurement is only implemented on Windows.

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


Send feedback on this subject.