core-async

2021-01-17T18:43:29.041Z

any idea why a thread/go-block that’s blocked/parked on a channel does not resume when we close that channel (channel closing happens after it’s already blocked/parked) e.g.

(def c (chan))

(future
  (alt!!
    [[c "value"]] :done))

(close! c) ;; expected alt!! to return since all its clauses are never going to succeed now

2021-01-19T14:22:57.043500Z

I use this for these cases to ensure the channels are not blocking anything when they're closed

(defn drain! [ch]
  (a/close! ch)
  (->> (repeatedly #(a/poll! ch))
       (take-while identity)
       doall))

2021-01-19T14:23:46.043800Z

did think of this. i might as well proceed with this for now and think of a clean strategy later

2021-01-17T19:20:38.041100Z

ok nevermind. understood. the expectations with writes is that someone may want to read it

2021-01-17T19:21:19.041300Z

and once all reads have happened the thread/goroutine will unblock

2021-01-17T22:08:47.041500Z

There are some bugs open for this