Asynchronous clojure.core.async/alts!!-保证只有一个通道工作?
当Asynchronous clojure.core.async/alts!!-保证只有一个通道工作?,asynchronous,clojure,Asynchronous,Clojure,当alts或高度时,是否保证只从或放入其中一个端口 (let [[value channel] (alts!! [c1 c2 c3 [1 c4]])] (cond (= channel c1) ; at this point, is it guaranteed that alts!! ; did not take from c2 and c3, and did not call (>!! c4 1)? (do-something
alts代码>或<代码>高度调用code>时,是否保证只从或放入其中一个端口
(let [[value channel] (alts!! [c1 c2 c3 [1 c4]])]
(cond (= channel c1)
; at this point, is it guaranteed that alts!!
; did not take from c2 and c3, and did not call (>!! c4 1)?
(do-something)))
我在文档中找不到与此相关的任何内容。我猜它是未定义的?根据alts
的函数“最多完成一个的多个通道操作。[…]”
这意味着调用函数时,端口上只会执行一次或零次(即,它将停止)操作。哪个操作是非确定性的,如docstring中所述:“除非:priority
选项为true,否则如果有多个端口操作准备就绪,则将做出非确定性选择”。是,这就是alts的要点!