Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast to subscribe chans in separate goroutines #2

Open
jsimnz opened this issue Sep 18, 2014 · 1 comment
Open

Broadcast to subscribe chans in separate goroutines #2

jsimnz opened this issue Sep 18, 2014 · 1 comment

Comments

@jsimnz
Copy link

jsimnz commented Sep 18, 2014

When a Post is made for an event, a for-loop is used to broadcast the event to all the channel registered to that event.

But the send down the goroutine is a blocking call, and the channels are non-buffered, so it may block indefinately trying to send to the first channel, even though there are others also registered on that channel.

Basically all code that looks like this:

for _, outputChan := range outChans {
    outputChan <- data
}

Should look like this

for _, outputChan := range outChans {
    go outputChan <- data
}

PS. I know this repo hasnt been updated in 2 years, but this was a concern of mine while using it. I'm happy to submit a pull request if I know it'll get merged in.

@mreiferson
Copy link
Contributor

The end-user provides the channel to send to, it's entirely up to them to provide buffered channels so that the calls won't block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants