Chapter 5. Locks, Blocks, and Better Channels
Now that we're starting to get a good grasp of utilizing goroutines in safe and consistent ways, it's time to look a bit more at what causes code blocking and deadlocks. Let's also explore the sync
package and dive into some profiling and analysis.
So far, we've built some relatively basic goroutines and complementary channels, but we now need to utilize some more complex communication channels between our goroutines. To do this, we'll implement more custom data types and apply them directly to channels.
We've not yet looked at some of Go's lower-level tools for synchronization and analysis, so we'll explore sync.atomic
, a package that—along with sync.Mutex
—allows for more granular control over state.
Finally, we'll delve into pprof, a fabulous tool provided by Go that lets us analyze our binaries for detailed information about our goroutines, threads, overall heap, and blocking...