-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Proposal: Adding example on Condition Variables #347
Comments
Not objecting per se, but do note that |
I'm open to this, but I don't think I've ever used |
I've used A concrete example where I've found it very idiomatic is for woker-coordinator communication where there are sequential phases of computation, for example Map Reduce. E.g. Coordinator has both map tasks and reduce tasks, reduce tasks can only run after all map tasks are done. In this scenario workers can ask the coordinator for a task and if no more map tasks are available then the worker waits on a condition variable. Once the coordinator knows all map tasks are complete it broadcasts on the condition variable so awaiting workers can be assigned a reduce task. My guess is that the scenario can be distilled into a more succinct example, but it'd be great to hear your thoughts first. |
@JJGO if you haven't seen it, I recommend checking out Bryan Mill's Rethinking Classical Concurrency patterns. The slides with speaker notes are at https://drive.google.com/file/d/1nPdvhB0PutEJzdCq5ms6UI58dp50fcAN/view -- start on page 37 for cond vars; you can also find a video of the talk online. |
Bryan takes a fairly esoteric view on what are pretty common synchronization primitives. +1 to a sync.Cond example, but be careful! :) |
Would you be open to having a page on Condition Variables, i.e.
sync.Cond
? It could go right after the mutex page and I believe it'd be a great resource since neither the go tour nor the docs have good examples/motivation on this synchronization primitive.I'd be happy to contribute with a PR, but I thought I might ask before devoting the time to it in case the feature is considered too advanced for the tutorial.
And thanks for maintaining such a high quality learning resource!
The text was updated successfully, but these errors were encountered: