Changeset 8489


Ignore:
Timestamp:
Feb 14, 2008, 9:10:47 AM (12 years ago)
Author:
gb
Message:

WITH-INPUT-TIMEOUT, WITH-OUTPUT-TIMEOUT.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/macros.lisp

    r8269 r8489  
    35683568  consing when N is a trivial constant integer."
    35693569  `(car (nthcdr ,n (multiple-value-list ,form))))
     3570
     3571
     3572
     3573(defmacro with-input-timeout (((stream-var &optional (stream-form stream-var)) timeout) &body body)
     3574  "Execute body with STREAM-VAR bound to STREAM-FORM and with that stream's
     3575stream-input-timeout set to TIMEOUT."
     3576  (let* ((old-input-timeout (gensym))
     3577         (stream (gensym)))
     3578    `(let* ((,stream ,stream-form)
     3579            (,stream-var ,stream)
     3580            (,old-input-timeout (stream-input-timeout ,stream)))
     3581      (unwind-protect
     3582           (progn
     3583             (setf (stream-input-timeout ,stream) ,timeout)
     3584             ,@body)
     3585        (setf (stream-input-timeout ,stream) ,old-input-timeout)))))
     3586
     3587(defmacro with-output-timeout (((stream-var &optional (stream-form stream-var)) timeout) &body body)
     3588  "Execute body with STREAM-VAR bound to STREAM-FORM and with that stream's
     3589stream-output-timeout set to TIMEOUT."
     3590  (let* ((old-output-timeout (gensym))
     3591         (stream (gensym)))
     3592    `(let* ((,stream ,stream-form)
     3593            (,stream-var ,stream)
     3594            (,old-output-timeout (stream-output-timeout ,stream)))
     3595      (unwind-protect
     3596           (progn
     3597             (setf (stream-output-timeout ,stream) ,timeout)
     3598             ,@body)
     3599        (setf (stream-output-timeout ,stream) ,old-output-timeout)))))
Note: See TracChangeset for help on using the changeset viewer.