Any API that lets you peek at the "state" of a channel is a surefire source of race conditions. So no, public API-wise, there isn't any way to do what you want. In theory, you can peek at the internals using reflection to get that information, but don't do that!
Instead, you can simply *count* yourself. Stick an extra go-loop on either end that swaps an atom with inc or dec. On Saturday, January 11, 2014 12:19:51 PM UTC-5, t x wrote: > > Hi, > > I have a clojure.core.async.chan > > Is there a way to figure out the # of elements currently queued on the > channel? (preferably in O(1) time) > > I don't want to actually take any item off the channel, I just want a > progress bar, something like "there are 20 transactions ahead of you in > life to be processed" > > Thanks! > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.