1

我正在试验 core.async 的混音。似乎在混音中使输入通道静音将是实现背压的一种可能方式。我正在使用下面的代码:

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

评估 REPL 中的最后一行给出

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

上面的示例代码有什么问题?

谢谢!

4

1 回答 1

1

(def 混合器 (admix (mix output-chan) input-chan))

admix您分配to的返回值mixer,它是一个布尔值,而不是预期的混合器。尝试:

(def output-chan (chan))
(def input-chan (chan))
(def mixer (mix output-chan))
(admix mixer input-chan)
(toggle mixer {input-chan {:mute true}})
于 2016-04-12T02:09:48.640 回答