In a unit test I am checking that a core async channel is empty. I
couldn't find any `empty?` function for core async channels, and since
`<!!` blocks if there's no message, I ended up putting a sentinel on the
channel and verifying that the next message read is the one.
(let [sentinel (keyword (gensym))]
(is (= sentinel (do (>!! channel sentinel)
(<!! channel)))))))
This appears to work fine, but how would I do it if it was not a test,
and I couldn't put random messages on the channel? Would I have to use
`alts!!` and a timeout?
Stig
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.