anchor.diff:                                         &key timeout wait-function)
     (do-port-force-output queue)
     (check-schedule queue)
  -  (process-next-event (event-queue-port queue) :timeout 0)
  -  (loop
  -     with port = (event-queue-port queue)
  -     with timeout-time = (and timeout (+ timeout (now)))
  -     do
  -       (cond ((event-queue-head queue)
  -              (return t))
  -             ((and timeout-time (> (now) timeout-time))
  -              (return (values nil :timeout)))
  -             ((multiple-value-bind (available reason)
  -                  (let* ((schedule-time (event-schedule-time queue))
  -                         (decay (compute-decay timeout-time schedule-time)))
  -                    (process-next-event port
  -                                        :timeout decay
  -                                        :wait-function wait-function))
  -                (and (null available)
  -                     (eql reason :wait-function)))
  -              (return (values nil :wait-function)))
  -             (t (check-schedule queue)))))
  +  (let ((port (event-queue-port queue)))
  +   (multiple-value-bind (available reason)
  +       (process-next-event port :timeout 0
  +                                :wait-function wait-function)
  +     (declare (ignore available))
  +     (cond ((eq reason :wait-function)
  +            (return-from event-queue-listen-or-wait
  +              (values nil :wait-function)))
  +           ((event-queue-head queue)
  +            (return-from event-queue-listen-or-wait
  +              t))))
  +    (loop
  +      with timeout-time = (and timeout (+ timeout (now)))
  +      do (cond ((maybe-funcall wait-function)
  +                (return (values nil :wait-function)))
  +               ((event-queue-head queue)
  +                (return t))
  +               ((and timeout-time (> (now) timeout-time))
  +                (return (values nil :timeout)))
  +               ((multiple-value-bind (available reason)
  +                    (let* ((schedule-time (event-schedule-time queue))
  +                           (decay (compute-decay timeout-time schedule-time)))
  +                      (process-next-event port
  +                                          :timeout decay
  +                                          :wait-function wait-function))
  +                  (when (null available)
  +                    (return (values nil reason)))))
  +               (t (check-schedule queue))))))
   
   (defmethod event-queue-listen ((queue simple-event-queue))
     (event-queue-listen-or-wait queue :timeout 0))
  
positive.code: return NIL."))
  
  (defgeneric event-queue-read-with-timeout (event-queue timeout wait-function)
    (:documentation "Reads one event from the queue, if there is no event before
  timeout returns NIL."))
  
  (defgeneric event-queue-append (event-queue item)
    (:documentation "Append the item at the end of the queue. Does event compression."))
  
negative.code: 
  (defmethod event-queue-read-with-timeout ((queue simple-event-queue) timeout wait-function)
    (do-port-force-output queue)
    ;; Preemptive check (timeout may be past due or wait-function may
    ;; already return true). -- jd 2020-01-22
    (check-schedule queue)
    (let ((port (event-queue-port queue)))
      (multiple-value-bind (available reason)
          (process-next-event port :timeout 0
                                   :wait-function wait-function)
        (declare (ignore available))
        (cond ((eq reason :wait-function)
               (return-from event-queue-read-with-timeout
                 (values nil :wait-function)))
              ((event-queue-head queue)
               (return-from event-queue-read-with-timeout
                 (%event-queue-read queue)))))
      (loop
        with timeout-time = (and timeout (+ timeout (now)))
        do (cond ((maybe-funcall wait-function)
                  (return (values nil :wait-function)))
                 ((event-queue-head queue)
                  (return (%event-queue-read queue)))
                 ((and timeout-time (> (now) timeout-time))
                  (return (values nil :timeout)))
                 ((multiple-value-bind (available reason)
                      (let* ((schedule-time (event-schedule-time queue))
                             (decay (compute-decay timeout-time schedule-time)))
                        (process-next-event port
                                            :timeout decay
                                            :wait-function wait-function))
                    (when (null available)
                      (return (values nil reason)))))
                 (t (check-schedule queue))))))
  
  (defmethod event-queue-append ((queue simple-event-queue) item)
    (labels ((append-event ()
  