       (doseq [[sma-old ss-buf] reborn-smasN]
         (ago-revive-state-machine ago-world sma-old ss-buf))
       ago-world))
-

    (active? [_] (active-cb))
    (commit [_] (when (active-cb) f))))

(defn compare-segvs [segv-x segv-y]
  (loop [xs segv-x
         ys segv-y]
    (let [x (first xs)
          y (first ys)]
      (cond (= nil x y) 0
            (nil? x) 1
            (nil? y) -1
            (= x y) (recur (rest xs) (rest ys))
            :else (- x y)))))

(defn ago-take [state blk ^not-native c]
  (let [active? #(<= (compare-segvs (chan-segv c) (:segv @(chan-ago-world c))) 0)]
    (if-let [cb (protocols/take!
                 c (fn-handler
                    active?

(defn ago-return-chan [state value]
  (let [^not-native c (aget state ioc-helpers/USER-START-IDX)
        ago-world (chan-ago-world c)
        active? #(segv-alive? ago-world (chan-segv c))]
    (when (active?)
      (when-not (nil? value)
        (protocols/put! c value (fn-handler active? (fn [] nil))))
