Fork me on GitHub
#core-async
<
2018-01-30
>
nooga19:01:53

is it ok to do (defn blah [] ... (alt!! ...))(go ... (blah) ...)? Will it work the same way as putting (alt! ...) instead of the (blah) call?

hiredman19:01:06

the operators with double bangs really and truely block a thread, the operators with single bangs yield the thread back to the threadpool

nooga21:01:19

so blah should be a macro then

hiredman21:01:50

or blah should should be a go block

hiredman21:01:29

(defn blah [] (go (alt! ...))) (go (<! (blah)))

nooga21:01:28

blah is basically (alt! stop-chan false :default :keep-going) to check if go-loop should continue

nooga21:01:07

I wanted to abstract it away so that the go-loop looks cleaner

noisesmith21:01:12

go blocks can't do their thing across function calls - they are macro form rewrites

noisesmith21:01:06

so your choices are a) block a go thread (bad, the number is small, they shouldn't be blocked) b) make a macro that expands in the go block or c) a function that returns a channel, which you use properly from inside the block

nooga21:01:31

understood

nooga21:01:49

so @hiredman’s example will work in this case