trivial-timeout
OS- and implementation-independent access to timeouts.

Repository: https://github.com/gwkkwg/trivial-timeout

License: MIT

Quick assessment (2024-04-02)

There are a few different approaches to writing a with-timeout macro:

  1. Timed wait on a semaphore. See lines 65–82 of with-timeout.lisp.
  2. SLEEP followed by an interrupt. See lines 158–170 of muproc-clozure.lisp.
  3. Unix signals, via setitimer(2). SBCL has this—see the manual on timers.
Clearly, both of the first two approaches are synchronous (blocking) and require a separate thread. In the first approach, the new thread is the one subject to timeout (i.e. being killed) whereas in the second approach, the new thread is the one enforcing the timeout. By contrast, the third approach has the advantage of being completely asynchronous, so it doesn't require a separate thread. The downside, of course, is that non-Unix operating systems do not have Unix signals per se, though one can find something roughly equivalent in many systems. (For example, there's SYS$SETIMR in VMS, and even good ol' DOS has the timer tick interrupt.)


Topic: concurrency