Tcl library for Go-style concurrency based on Communicating Sequential Processes
github.com
github.com
I have seen Go code that twists and contorts itself to solely use channels when straightforward mutexes would have made the code easier to understand and reason about.
Libraries like this and channels should only be seen as another tool to consider when writing concurrent software rather than treating them like the panacea for concurrent software.
It feels like a lesser sin to use channels in clever ways to recreate mutexes or other patterns than the other way around. But it’s definitely true that they are juiced up to make tradeoffs that are morally wrong for some things.
This approach can be taken too far. Reference counts may be best done
by putting a mutex around an integer variable, for instance.
But as a high-level approach, using channels to control access makes it easier
to write clear, correct programs.
I'm sure somebody has been banging a "Go programs should never use mutexes" drum, but it hasn't ever been the position of the Go team that channels are a panacea or that mutexes _shouldn't_ be used, as far as I've ever seen.TLDR; CSP is a great model for concurrency but barely anyone uses it.
I've read it after inventing similar concept and implementing it on top of Python+Redis. So embarrassing.
"This concurrency model may also be seen as a generalization of Unix named pipes where processes and pipes correspond to coroutines and channels."
This is in keeping with tcl, bash, and glue languages - I love this. I'm about to go looking for it, but if anyone can point me to a good reference on Go's concurrency model or it's best practices I would be much obliged.Keep reading the next thing until they stop talking about concurrency.
https://go.dev/doc/effective_go#concurrency
And go by example, of course: https://gobyexample.com/goroutines
I've used examples from this presentation at work
https://www.cc.gatech.edu/classes/AY2010/cs4210_fall/papers/...
And the HN discussion related to it, https://news.ycombinator.com/item?id=17297325