Fork me on GitHub
#core-async
<
2017-12-19
>
jjfine21:12:41

i'm trying to gracefully stop some code that's using mult/tap. i'm shutting down the producer that writes to the mult and waiting until all of the mult and tap buffers are empty. but that won't be enough if one of the tap consumers takes a bit of time to process the last item coming out of the tap. i started looking at keeping track of whether the consumers are processing an item or waiting for a new one. but i can't figure out a way keep track of that kind of state without a race condition. has anyone attempted something like this? i'm wondering if i should be using a part of core async other than mult/tap

noisesmith21:12:05

@jjfine why not wait for the code containing the consumers of the taps to exit? eg. wait on the channel that go returned

jjfine21:12:27

oh wow that's too obvious

noisesmith21:12:59

np - it takes a while for the natural / easy choice to be intuitive with core.async haha

noisesmith21:12:09

but yeah, a good rule of thumb is that it’s easier to wait on a channel rather than a consumer, and you can always ensure that consumer closes a channel (in fact it is probably doing so already whether you think of it that way or not)

hiredman21:12:09

I invariably end up passing a second "exit" channel to anything I launch, and use alts to consume from either whatever channel to get data and do whatever(and then loop), or consume from the exit channel and exit