Fork me on GitHub

(ns test
  (:require [clojure.core.async :as a]))

(def c (a/chan 1 (mapcat (fn [x] (doall (range 0 x))))))
(a/>!! c 10000)
(println (a/<!! c)) ; where is the giant seq buffered?


I’m wondering how mapcat or other “expanding” transducer functions work with core.async. It appears the channel will happily buffer 10,000 values, but are they buffered efficiently? Does the core.async implementation buffer them in a separate “special” place?

Alex Miller (Clojure team)03:10:21

buffers are allowed to buffer extra values created by an expanding transducer

Alex Miller (Clojure team)03:10:27

they’re in the buffer

Alex Miller (Clojure team)03:10:56

of the channel you created so it’s really up to you where they’re buffered

Alex Miller (Clojure team)03:10:16

if this is bad for you, then don’t do that :)