| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |
Arguments: (seconds &body timeout-body) &body body
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-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.
| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |