• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

SWI-Prolog C-library
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog C-library
        • Introduction
        • library(process): Create processes and redirect I/O
        • library(filesex): Extended operations on files
        • library(uid): User and group management on Unix systems
        • library(syslog): Unix syslog interface
        • library(socket): Network socket (TCP and UDP) library
        • The stream_pool library
        • library(uri): Process URIs
        • CGI Support library
        • Password encryption library
        • library(uuid): Universally Unique Identifier (UUID) Library
        • SHA* Secure Hash Algorithms
        • library(md5): MD5 hashes
        • library(hash_stream): Maintain a hash on a stream
        • Memory files
        • library(time): Time and alarm library
          • alarm/3
          • alarm/4
          • alarm_at/3
          • alarm_at/4
          • install_alarm/1
          • install_alarm/2
          • uninstall_alarm/1
          • remove_alarm/1
          • current_alarm/4
          • call_with_time_limit/2
          • call_with_time_limit/3
        • library(unix): Unix specific operations
        • Limiting process resources
        • library(udp_broadcast): A UDP broadcast proxy
        • library(prolog_stream): A stream with Prolog callbacks

16 library(time): Time and alarm library

The 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 use call_with_time_limit/2.

[det]alarm(+Time, :Callable, -Id)
[det]alarm(+Time, :Callable, -Id, +Options)
Set up an alarm to be signaled Time seconds from now. If the alarm expires, Callable is called asynchronously. Callable can be used to raise an exception using throw/1 to abort some execution.

Options is a list of Name(Value) options. Currently defined options are:

remove(Bool)
If true (default false), remove the alarm-event (as remove_alarm/1) after it has been fired.
install(Bool)
If false (default true) do not install the alarm. It must be installed separately using install_alarm/1.
[det]alarm_at(+Time, :Callable, -Id)
[det]alarm_at(+Time, :Callable, -Id, +Options)
As alarm/3 and alarm/4, but schedule the alarm at an absolute point in time.
See also
date_time_stamp/2.
[det]install_alarm(+Id)
[det]install_alarm(+Id, +RelTime)
Install an alarm allocated using alarm/4 with the install(false) option or de-activated using uninstall_alarm/1. With a given RelTime, the alarm is scheduled at the RelTime from now. Otherwise it is scheduled on the same (absolute) time on which is was created.
[det]uninstall_alarm(+Id)
De-activate an alarm. This does not invalidate Id, but ensures that the alarm will not fire. The alarm can be rescheduled to the original time using install_alarm/1 or to a new time using install_alarm/2.
[det]remove_alarm(+Id)
Remove an alarm. If it has not yet been fired, it never will.
[nondet]current_alarm(?Time, :Goal, ?Id, ?Status)
Enumerate the alarms in the schedule. Time is the absolute time the event is scheduled for (see also get_time/1). Goal is the goal to execute, Id is the identifier and Status is the scheduling status. It takes the value done if the alarm has been fired, next if the event is the next to be executed and scheduled otherwise.
[det]call_with_time_limit(+Time, :Goal)
[det]call_with_time_limit(+Time, :Goal, +Context)
Call Goal, while watching out for a (wall-time) limit. If this limit is exceeded, the exception time_limit_exceeded is raised. call_with_time_limit/3 throws time_limit_exceeded(Context). Goal is called as in once/1.
throws
time_limit_exceeded (call_with_time_limit/2) or time_limit_exceeded(Context) (call_with_time_limit/3).

ClioPatria (version V3.1.1-51-ga0b30a5)