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

More idiomatic Go concurrency #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yarcat
Copy link
Contributor

@yarcat yarcat commented Sep 9, 2020

Back to using semaphores removed by #126.

This solution is a bit more idiomatic and resonates with "Don't communicate by
sharing memory, share memory by communicating." Go proverb 1.

Similar approach to use buffered channel as a semaphore to limit throughput is
discussed in Effective Go 2.

In addition to that it's almost twice less code (see those +19 and -35 lines).

Footnotes

  1. https://go-proverbs.github.io/

  2. https://golang.org/doc/effective_go.html#channels

This solution is a bit more idiomatic and resonates with "Don't communicate by
sharing memory, share memory by communicating." Go proverb[^1].

Similar approach to use buffered channel as a semaphore to limit throughput is
discussed in Effective Go[^2].

[^1]: https://go-proverbs.github.io/
[^2]: https://golang.org/doc/effective_go.html#channels
@yarcat
Copy link
Contributor Author

yarcat commented Sep 10, 2020

@tklauser @rakyll Could you please take a look? This change doesn't really modify any functionality -- it's a pure stylistic cleanup. And now, as we have tests, I feel very confident about not breaking anything w/ it.

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.

1 participant