1

I am experimenting with core.async's mixes. It seems that muting an input channel in a mix would be one of possible ways of implementing backpressure. I am using the code below:

(def output-chan (chan))
(def input-chan (chan))
(def mixer (admix (mix output-chan) input-chan))
(toggle mixer {input-chan {:mute true}})

Evaluating last line in the REPL gives

CompilerException java.lang.IllegalArgumentException: No implementation of method: :toggle* of protocol: #'clojure.core.async/Mix found for class: java.lang.Boolean.

What is wrong with the above example code?

Thanks!

siphiuel
  • 3,480
  • 4
  • 31
  • 34

1 Answers1

1

(def mixer (admix (mix output-chan) input-chan))

You assign the return value of admix to mixer, which is a boolean and not the expected mixer. Try:

(def output-chan (chan))
(def input-chan (chan))
(def mixer (mix output-chan))
(admix mixer input-chan)
(toggle mixer {input-chan {:mute true}})
Erik Dannenberg
  • 5,716
  • 2
  • 16
  • 21