Fork me on GitHub
#core-async
<
2015-11-13
>
danielgrosse12:11:40

Hello, a short question. I have a function which is called, when a message is received. Than it puts the message into a channel with

(go (>! chan msg))
in another ns i take this channel and print it to the repl with
(go (println (<! chan))
. When I now send a message, the channelcontent is only printed once. Doesn’t the println take the value out of the channel and unblocks it?

swizzard13:11:04

@danielgrosse: so you’re sending multiple messages but only the first one gets printed out?

danielgrosse13:11:30

Yes. just discovered, I had to change it to

(go (while true (println (<! chan))))
to get it work

swizzard13:11:37

friggin’ slack

swizzard13:11:43

that won’t work w/o the ! at the end

danielgrosse13:11:49

What if i put continuous something into the channel without taking it out. Will it block anytime?

swizzard13:11:03

depends on how you construct the channel

swizzard13:11:21

a plain (chan) will block first time every time

swizzard13:11:47

but you can set a length—`(chan 5)` will only block on the 6th item

swizzard13:11:03

there’s also like fancy sliding buffer stuff, but i don’t remember the details