anchor.diff:    channel)
   
   
  +;;;;;;;;;;;;;;;;;;;;;;;;;;
  +;;; CONTINUOUS READING ;;;
  +;;;;;;;;;;;;;;;;;;;;;;;;;;
  +
  +;;; maintain a background thread that will continuously read the
  +;;; channel
  +
  +(defun make-listener (channel-name &key last)
  +  (let ((lock (sb-thread:make-mutex))
  +        (buffer nil)
  +        (continue t))
  +    (let ((thread  ; start the listening thread
  +           (sb-thread:make-thread
  +            (lambda () (let ((channel (ach-open channel-name
  +                                           :direction :input :last last)))
  +                    (unwind-protect (loop
  +                                       while continue
  +                                       for tmp-buffer = (ach-read channel)
  +                                       do (sb-thread:with-mutex (lock)
  +                                            (setq buffer tmp-buffer)))
  +                      (ach-close channel))))
  +            :name (concatenate 'string "ach-listener-" channel-name))))
  +      ;; return a closure to get the next buffer or terminate the listener
  +      (lambda (&key terminate)
  +        (if terminate
  +            ;; stop the listener
  +            (progn
  +              ;; FIXME: be more robust
  +              (setq continue nil)
  +              (sb-thread:join-thread thread))
  +            ;; get the buffer
  +            (progn
  +              (sb-thread:with-mutex (lock)
  +                (copy-seq buffer))))))))
  +
  +
  
positive.code:                "Invalid size delimiter: ~A" (subseq size-buf 8))
      (let* ((size (decode-uint size-buf :big 4))
             ;;(buffer (make-array size :element-type '(unsigned-byte 8))))
             (buffer (make-octet-vector size)))
        ;(read-bytes-dammit buffer s)
        (read-sequence buffer s)
        buffer)))
  
negative.code: (defun make-size-buf ()
    (make-octet-vector 12))
  
  (defun ach-read (channel &optional buffer)
    "read a frame from the channel"
    (declare (type (or null octet-vector) buffer))
    (assert (eq :input (channel-direction channel)) ()
            "Channel direction must be :INPUT, not ~S"
            (channel-direction channel))
  