I guess the main problem I am having is coordinating the shutdown of
multiple what I would call "queue workers" - basically one input channel,
one output channel, and about 1000 goroutines processing input, dropping
some data, and sending on the output channel. What's the standard pattern
for recognizing that the input channel has closed, then closing the output
channel when processing has finished without losing data (e.g. "ERROR -
output channel already closed"). I thought that the input shutdown message
could only be received by one queue worker, not all of them.

On Tue, Nov 18, 2014 at 7:17 AM, Jesper Louis Andersen wrote:

On Mon, Nov 17, 2014 at 10:04 PM, Philip Thomas wrote:

Can you examine the size of the buffer in the channel, e.g. to see if it
is empty or full, without modifying the channel?

Don't do this by asking for the length of the channel. Just try to read a
value out of the channel without blocking and handle the events from there.
It is pretty important to make sure your channel operations are safe from
data races. Otherwise you introduce small bugs in the code base which are
hard to find later on. It tend to be better to drive it by events on the
channels rather than looking at "side information".

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 9 | next ›
Discussion Overview
groupgolang-nuts @
postedNov 17, '14 at 9:04p
activeNov 18, '14 at 11:04p



site design / logo © 2021 Grokbase