         (loop []
           (when-let [[evt val] (poll-queue current-state)]
             (cond
-             (= :interest-ops evt)
-             (handle-interest-ops state upstream)
+             (#{:pause :resume} evt)
+             (handle-interest-ops state evt upstream)
 
              (= :schedule evt)
              (val)

      (reset! event-lock true))))

(defn- handle-interest-ops
  [state upstream]
  (let [current-state @state
        writable?     (.writable? current-state)
        ch            (.ch current-state)]
    (when (not= writable? (.isWritable ch))
      (swap! state #(assoc % :writable? (not writable?)))
      (upstream (if writable? :pause :resume) nil))))

;; Handles sending messages upstream in a sane and thread-safe way.
;;

(defn- poll-queue*
  [current-state]
  (or (.. current-state state-queue poll)
      (.. current-state message-queue poll)
      ;; (and (or (.. current-state ch isReadable)
      ;;          (not (.. current-state ch isOpen)))
      ;;      (.. current-state message-queue poll))
      ))

(defn- poll-queue
  [current-state]
