missionary 2024-09-18

Absolute Negativity 2024-09-18T17:15:10.600169Z

Why did I have to call process n times before it'd stop here?

(defn f []
    (m/ap
      (let [x> (m/seed [1 2 3])
            x  (m/?> ##Inf x>)]
        (try
          (m/?> (m/ap (loop [] ;; yields x every sec
                        (m/amb x
                          (do (m/? (m/sleep 1000))
                            (recur))))))
          (catch missionary.Cancelled _ (m/amb))))))

  (def t ((m/reduce (fn [_ x] (log/info x)) nil (f))
          (fn [_] (log/info :done))
          (fn [e] (log/error e))))

  (dotimes [_ 2] (t)) ; still printing n
  (dotimes [_ 3] (t)) ; => printed :done

bug. calling (t) once should cancel the 3 child branches and terminate immediately

🐛 1

but he is catching the cancellation and not rethrowing it, so doesn't it make sense?

I would not recommend that but it's well defined and allowed

Absolute Negativity 2024-09-19T13:13:34.035719Z

In my original problem, [1 2 3] that goes into m/seed came from m/?<. I want that to change the values yielded by the inner loop, hence I didn't throw Cancelled when the values yielding processes are cancelled.