Swimming pool semaphores
summary
Shows two concrete semaphore patterns implemented as buffered channel tokens, including using a channel-as-shelf where initial items encode the counter and a token-take pattern, with a swimming-pool example limited to capacity 12. Adds practical features: timeout via select, cancellation, and atomic multi-token acquire. Demonstrates extensions to sync.WaitGroup and errgroup.Group to cap concurrency and avoid DB connection exhaustion, with ~50-line, ready-to-use code that compiles and is production-ready.
AI-written summary · about
chapters (5)
- 0:00Swimming pool semaphores
- 3:58Implementing with Go channels
- 6:27Advanced use with timeouts
- 8:36Why semaphores matter
- 11:28Semaphores for correct concurrency
related talks
04mSemaphores
43mDeep dive into the sync package
24mMastering Concurrency in Go: From Patterns to Production
32mConcurrency Patterns in Go
26mConcurrency primitives of Golang - how to use and how not to
03h 29mConcurrency with Clojure
01h 07mThe C++20 Synchronization Library
27mProduction Ready Concurrency
