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

limit the number of goroutines #97

Merged
merged 1 commit into from
Apr 26, 2016
Merged

limit the number of goroutines #97

merged 1 commit into from
Apr 26, 2016

Conversation

achille-roussel
Copy link
Contributor

@f2prateek

Following up on our conversation, this should limit the number of goroutines spawned by the client and block if too many are in use already.

@f2prateek
Copy link
Contributor

Neat, haven't used sync.Cond before. I think we can simplify by using a semaphore directly though https://github.com/f2prateek/semaphore if we want to simplify.

LGTM!

@f2prateek f2prateek merged commit 2d840d8 into master Apr 26, 2016
@achille-roussel
Copy link
Contributor Author

Yep, a semaphore primitive would be great to have in Go... I don't know if Go optimizes allocation of make(chan struct, 1000) to not allocate 1KB+ of memory for the semaphore, if it does it's great, if not I'd rather use sync.Cond + counter, which seems like a more efficient way to manage the semaphore.

The Channel has the advantage of being injectable in a select, I'll probably do that in 3.0.0 to wait for c.quit as well.

@achille-roussel achille-roussel deleted the limit-goroutines branch April 26, 2016 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants