Re[3]: [hunchentoot-devel] port to sbcl win32: timouts are notimplemented

Anton Vodonosov vodonosov at mail.ru
Sat Jul 14 00:34:05 UTC 2007


It's strange. Today I've tried to load hunchentoot via asdf
and the code I've sent in previous message don't work.

I fixed it a little and now it's possible to load hunchentoot
using asdf and sbcl win32:

;; Determine whether sb-ext:with-timeout is supported;
;; we can't just check (FIND-SYMBOL "WITH-TIMEOUT" "SB-EXT")
;; because, for example in sbcl 1.0.6 for win32, the function
;; is present, but doesn't work (it signals UNDEFINED-FUNCTION: 
;; SB-UNIX:UNIX-SETITIMER)
(eval-when (:compile-toplevel :load-toplevel :execute)     
  (defun ensured-sleep-millis (milliseconds)
    "Sleeps (in fact loops) not less then MILLISECONDS number of milliseconds;
the minimal sleep time is one internal time unit. Don't use this function
for large time values, because it eats processor power."
    (do ((start-time (get-internal-real-time)))
    ((< (+ start-time (ceiling (* internal-time-units-per-second 
                      (/ milliseconds 1000))))
        (get-internal-real-time)))))
  (cl:handler-case
      (sb-ext:with-timeout 0.0000001 (ensured-sleep-millis 5))
    (sb-ext:timeout () (pushnew :hunchentoot-sbcl-with-timeout *features*))
    (cl:t ())))

(defmacro with-timeout ((seconds &body timeout-forms) &body body)
  "Executes the code BODY and returns the results of the last
form but stops execution after SECONDS seconds and then instead
executes the code in TIMEOUT-FORMS."
  (declare (ignorable seconds timeout-forms body))
  #-:hunchentoot-sbcl-with-timeout `(cl:progn , at body)
  #+:hunchentoot-sbcl-with-timeout
  `(cl:handler-case
     (sb-ext:with-timeout ,seconds , at body)
     (sb-ext:timeout () , at timeout-forms)))


BTW, in the top of port-sbcl.lisp there is
#-:sb-thread
(eval-when (:compile-toplevel :load-toplevel :execute)
  (warn "Without thread support, this library is only useful for development."))

It's quite annoying because compilation with asdf fails
on this (today; strange again I don't remember that it 
happened before)

Regards,
-Anton



More information about the Tbnl-devel mailing list