From: ·······@eurogaran.com
Subject: ANNOUNCE limitime
Date: 
Message-ID: <1193988013.981248.97190@k79g2000hse.googlegroups.com>
ANNOUNCE  New limitime library for download at:
http://www.eurogaran.com/downloads/lisp/limitools/limitime.lsp
...including the long-awaited with-max-time

Call for corrections:
- Those of you using Symbolics please confirm whether 100'ths of
a second instead of 60'ths are used for process-wait-with-timeout
- Those of you using MCL please modify source substituting
the 2 ocurrences of the word openmcl by mcl, and tell me if it worked.
Please send your comments to ······@eurogaran.com
Thank you.

From: Chris Russell
Subject: Re: ANNOUNCE limitime
Date: 
Message-ID: <1194019211.706571.114850@d55g2000hsg.googlegroups.com>
On 2 Nov, 07:20, ·······@eurogaran.com wrote:
> ANNOUNCE  New limitime library for download at:http://www.eurogaran.com/downloads/lisp/limitools/limitime.lsp
> ...including the long-awaited with-max-time
>
> Call for corrections:
> - Those of you using Symbolics please confirm whether 100'ths of
> a second instead of 60'ths are used for process-wait-with-timeout
> - Those of you using MCL please modify source substituting
> the 2 ocurrences of the word openmcl by mcl, and tell me if it worked.
> Please send your comments to ······@eurogaran.com
> Thank you.
Shouldn't finialtime be calculated at run time instead of compile
time?

---snip---
;Inside a macro...
 #+sbcl
  (let ((results (gensym))
        (computs (gensym))
        (finaltime (+ (get-internal-real-time)
                      (truncate (* seconds internal-time-units-per-
second))))
        (granularity 0.02)) ; poll every granularity seconds precision
    (declare (type integer finaltime)
             (type float granularity))

    `(let* ((,results nil)
            (,computs (sb-thread:make-thread
                       #'(lambda () (setq ,results (multiple-value-
list
 
(progn ,@body)))))))
      (declare (type list ,results)
               (sb-ext:muffle-conditions sb-ext:compiler-note))

      (loop while (and (not ,results) (< (get-internal-real-
time) ,finaltime))
       do (sleep ,granularity))

      (if (sb-thread:thread-alive-p ,computs)
        (sb-thread:terminate-thread ,computs))
      (values-list ,results)))
---snip---
From: ·······@eurogaran.com
Subject: Re: ANNOUNCE limitime
Date: 
Message-ID: <1194252985.615004.285310@o3g2000hsb.googlegroups.com>
On Nov 2, 5:00 pm, Chris Russell <·····················@gmail.com>
wrote:
> Shouldn't finaltime be calculated at run time instead of compile
> time?
>
Both ways should work. However, it should perform better this way.
I appreciate you have reviewed my code. Thanks.
There was indeed an error of concept in it that caused with-max-time
not to work properly when nested. This has now been corrected, so
please download the last version at
 http://www.eurogaran.com/downloads/lisp/limitools/limitime.lsp
Looking forward to your criticisms.
From: Madhu
Subject: Re: ANNOUNCE limitime
Date: 
Message-ID: <m38x54krhy.fsf@robolove.meer.net>
* ·······@eurogaran.com
| ANNOUNCE  New limitime library for download at:
| http://www.eurogaran.com/downloads/lisp/limitools/limitime.lsp
| ...including the long-awaited with-max-time

I noticed this does not support lisp implementations without threads.
Notably it does not support CMUCL. However I wanted to point out it is
possible to do what limittime.lsp is doing in CMUCL, in two ways:

On x86 CMUCL's MP by using the following function (written by Douglas
Crosher and placed in PD)

  (defun with-timeout-internal (timeout function &optional error-p)
    (catch 'timer-interrupt
      (let* ((current-process mp:*current-process*)
	     (timer-process (mp:make-process
			     #'(lambda ()
				 (sleep timeout)
				 (mp:process-interrupt
				  current-process
				  #'(lambda () (throw 'timer-interrupt nil))))
			     :name "Timeout timer")))
	(unwind-protect
	     (return-from with-timeout-internal (funcall function))
	  (mp:destroy-process timer-process))))
    (when error-p
      (error "Timeout: body took longer than ~d second(s) to complete."
	     timeout)))

But this may not work very well depending on your MP setup.  Another
solution would be to adapt Fred Gilham's TIMED-UNIX-PROCESS which he
posted on comp.lang.lisp

       From: Fred Gilham <······@snapdragon.csl.sri.com>
 Message-ID: <·················@snapdragon.csl.sri.com>
       Date: Tue, 05 Dec 2006 09:41:32 -0800
--
Madhu