Did you know ... Search Documentation:
timed_call.pl -- XSB timed call
PublicShow source

This module emulates the XSB built-in timed_call/2. As this is a built-in, this module is re-exported from library(dialect/xsb). It has been placed in a separete module to facilitate reuse and allow to not load this if the prerequisites (library(time) and multi-threading) are not satisfied.

Source timed_call(:Goal, :Options)
Emulation for XSB timed_call/2. Runs Goal as once/1 with timed interrupts. The interrupt goals are called as interrupts using the semantics of ignore/1: possible choice points are cut and failure is ignored. If the interrupt throws an exception this is propagated.

Options is a list of the terms below. At least one of the terms max/2 or repeating/2 must be present.

max(+MaxInterval, :MaxHandler)
Schedule a single interrupt calling MaxHandler at MaxInterval milliseconds from now.
repeating(+RepInterval, :RepHandler)
Schedule a repeating interrupt calling RepHandler each RepInterval milliseconds.
Nested calls to timed_call/2 are transformed into calls to once/1. Without nesting, a nested call raises a permission_error exception.
See also
- call_with_time_limit/2, alarm/4, thread_signal/2.
- This predicate is a generalization of the SWI-Prolog library(time) interface. It is left in the XSB emulation because it uses non-standard option syntax and the time is in milliseconds where all SWI-Prolog time handling uses seconds.