|Did you know ...||Search Documentation:|
|Time and alarm library|
This library is not available if SWI-Prolog is compiled without support for multiple threads.
library(time) provides timing and alarm functions.
Alarms are thread-specific, i.e., creating an alarm causes the alarm
goal to be called in the thread that created it. The predicate current_alarm/4
only reports alarms that are related to the calling thread. If a thread
terminates, all remaining alarms are silently removed. Most applications
The resolution of the alarm depends on the underlying implementation, which is based on pthread_cond_timedwait() (on Windows on the pthread emulation thereof). Long-running foreign predicates that do not call PL_handle_signals() may further delay the alarm. The relation to blocking system calls (sleep, reading from slow devices, etc.) is undefined and varies between implementations.
Options is a list of
terms. Defined options are:
alarm(Time, Callable, Id,).
install(false)or stopped using uninstall_alarm/1.
doneif the alarm has been called,
nextif it is the next to be fired and scheduled otherwise.
time_limit_exceeded. See catch/3.
Please note that this predicate uses alarm/4 and therefore its effect on long-running foreign code and system calls is undefined. Blocking I/O can be handled using the timeout option of set_stream/2 or waiting for input using wait_for_input/3.