MacroPackage: systemToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
Unrevised from 8.0 to 8.1.
8.0 version

with-timeout

Arguments: (seconds &body timeout-body) &body body

In releases prior to 7.0, the home package of the symbol naming this macro was the multiprocessing package. The symbol has been moved to the system package. This macro is available even when the process module is not loaded.

This macro evaluates the body as a progn body. If the evaluation of body does not complete within the specified interval, execution throws out of the body and the timeout-body forms are evaluated as a progn body, returning the result of the last form. The timeout-body forms are not evaluated if the body completes within seconds.

The value of seconds may be any real number. A negative or zero value causes the timeout-body to be executed immediately. This macro uses operating system utilities for timing so its granularity depends on the granularity of the operating system functions. We cannot in this page specify the granularity you will see (since this page is generic over many systems and environmental factors affect the result) but we can say that seconds of less than about 0.08 will always time out on most Unix systems. We strongly recommend that you test this macro to find out the granularity on your system.

Here is an example of code using sys:with-timeout. We define a variant of y-or-n-p which times out after a specified number of seconds, taking the default value specified in the arguments.

(defun y-or-n-p-with-timeout (seconds default &rest args)
  (sys:with-timeout (seconds (format t "[Timed out] ~a~%" default)
	     default)
	 (apply #'y-or-n-p args)))

See multiprocessing.htm for general information on multiprocessing in Allegro CL.


Copyright (c) 1998-2009, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.1. This page was not revised from the 8.0 page.
Created 2009.7.29.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
Unrevised from 8.0 to 8.1.
8.0 version