anchor.diff:       with lock = (event-queue-lock queue)
        with cv = (event-queue-processes queue)
        with timeout-time = (and timeout (+ timeout (now)))
  -     as decay = (compute-decay timeout-time (event-schedule-time queue))
        do
  -       (when decay (maxf decay 0))
  -       (with-recursive-lock-held (lock)
  +       (check-schedule queue)
  +       (with-lock-held (lock)
            (if-let ((event (%event-queue-read queue)))
              (return event)
              (cond ((maybe-funcall wait-function)
  
positive.code:                  ((and timeout-time (> (now) timeout-time))
                    (return (values nil :timeout)))
                   (t
                    (condition-wait cv lock decay)))))))
  
  (defmethod event-queue-append ((queue concurrent-event-queue) item)
    (with-recursive-lock-held ((event-queue-lock queue))
      (call-next-method)
      (condition-notify (event-queue-processes queue))))
  
  (defmethod event-queue-prepend ((queue concurrent-event-queue) item)
    (with-recursive-lock-held ((event-queue-lock queue))
      (call-next-method)
      (condition-notify (event-queue-processes queue))))
  
  (defmethod event-queue-peek ((queue concurrent-event-queue))
    (do-port-force-output queue)
    (with-recursive-lock-held ((event-queue-lock queue))
      (check-schedule queue)
      (first (event-queue-head queue))))
  
  (defmethod event-queue-peek-if (predicate (queue concurrent-event-queue))
    (do-port-force-output queue)
    (with-recursive-lock-held ((event-queue-lock queue))
      (find-if predicate (event-queue-head queue))))
  
  (defmethod event-queue-listen ((queue concurrent-event-queue))
    (do-port-force-output queue)
    (check-schedule queue)
    (not (null (event-queue-head queue))))
  
  (defmethod event-queue-listen-or-wait ((queue concurrent-event-queue)
                                         &key timeout wait-function)
  
negative.code:      with lock = (event-queue-lock queue)
       with cv = (event-queue-processes queue)
       with timeout-time = (and timeout (+ timeout (now)))
       do
         (check-schedule queue)
         (with-lock-held (lock)
           (cond ((event-queue-head queue)
                  (return t))
                 ((maybe-funcall wait-function)
                  (return (values nil :wait-function)))
                 ((and timeout-time (> (now) timeout-time))
                  (return (values nil :timeout)))
                 (wait-function
                  ;; We CLAMP decay when wait-function is present to
                  ;; ensure that we don't get stuck until next event
                  ;; arrives (or the timeout happens). It is busy wait
                  ;; with a lousy grain. -- jd 2019-06-06
                  (if-let ((decay (compute-decay timeout-time
                                                 (event-schedule-time queue))))
                    (condition-wait cv lock (min 0.01 decay))
                    (condition-wait cv lock 0.01)))
                 (t
                  (let ((decay (compute-decay timeout-time
                                              (event-schedule-time queue))))
                    (condition-wait cv lock decay)))))))
  
  
  