We encountered a thorny problem with
In some situations "No more than 1024 pending takes are allowed" is raised in an async-dispatch thread, even though there are actually only 1024 pending takes.
That situation can be triggered quickly with the following code:
(dotimes [_ 5000]
;; - start 1024 threads that all alt! on a common channel (ch) and on an individual channel (x)
;; - the common channel remains 'empty' all the time
;; - wakeup all theads twice via the x channel, which makes them loop.
;; - this quickly raises multiple 'No more than 1024 pending takes are allowed on a single channel.' assertions in an async-dispatch thread.
(let [ch (async/chan)
(mapv (fn [n]
(let [x (async/chan)]
x ([_] (recur))))
(doseq [x x-chans]
(dotimes [n wakeups]
(async/>!! x 42)))
Mac OS, JDK 8, Clojure 1.10.0, core-async 0.6.532