Go offline with the Player FM app!
013: Go's concurrency to the rescue
Manage episode 348463180 series 3302141
Go's worker queue pattern:
type WorderPool struct {
queue chan int
}
func (wp *WorkerPool) start() {
for i := 0; i < 500; i++ {
go funcIO {
for id := range wp.queue {
doSomething(id)
}
}()
}
}
func (wp *WorkerPool) add(id int) {
wp.queue <- id
}
Best way to show support for the pod is by sharing it around and buying my course.
44 episodes
Manage episode 348463180 series 3302141
Go's worker queue pattern:
type WorderPool struct {
queue chan int
}
func (wp *WorkerPool) start() {
for i := 0; i < 500; i++ {
go funcIO {
for id := range wp.queue {
doSomething(id)
}
}()
}
}
func (wp *WorkerPool) add(id int) {
wp.queue <- id
}
Best way to show support for the pod is by sharing it around and buying my course.
44 episodes
All episodes
×Welcome to Player FM!
Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.