I would like to know how to get the size of a channel in clojure. I tried it with count, but it's not supported. Clojure documentation is usally good, but this time I coudn't find anything about it.
Example:
(def channel1 (chan 3))
(println(count channel1))
Should be 3 but throws "count not supported on this type: ManyToManyChannel"
I found a solution.
(.buf (.buf ch)) ;; Get elements in buffer
;; => (:chan :on :elements)
(.count (.buf ch)) ;; Get number of elements in buffer
;; => 3
(.n (.buf ch)) ;; Get size of buffer
;; => 10
(.full? (.buf mychan)) ;; Is buffer full?
;; => false
Further reading here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With