Fork me on GitHub
#core-async
<
2018-03-01
>
blackawa02:03:50

I am core.async newbie, and do not understand concept of chan status(open/close). I want to check whether my chan is closed. Are there any function to check status of chan?

tanzoniteblack02:03:52

there are...but they're hidden, undocumented, and subject to change

tanzoniteblack02:03:38

clojure.core.async.impl.protocols/closed? will do what you want; but I believe it's generally better to try and architect your system so you don't need to care if a channel is closed

ghadi02:03:09

checking the closed status is almost certainly racey

ghadi02:03:25

we debated whether to include the predicate at all

noisesmith02:03:32

if you read or write to a chan, and the op returns nil, it's closed

noisesmith02:03:18

since the act of reading or writing doesn't have other side effects, it's safe to attempt the >!, <!, etc. and check return value and take other action if it returned nil

blackawa02:03:24

I wanted to check my chan status because my chan looks closed after processing first item. However, my mistake was to forget (recur) in my go-loop macro… :shit: Anyway, thank you for nice advice guys 🙏 🙏 🙏