2018-05-05 11:11 GMT+03:00 Andriy Pylypenko <bambys...@gmail.com>: > I'll note in passing that pools of goroutines are not the best idiom >> for Go. Starting new goroutines is cheap. It's generally simpler to >> spin up goroutines as needed then to keep a pool of goroutines around. >> In this model use a separate semaphore, such as a buffered channel, to >> limit the number of goroutines doing work concurrently. >> > > It's a good approach when there is no need to maintain other resources per > goroutine such as DB connection which you don't want to reconnect for every > work item. In that case one is forced to maintain a pool of those resources > which may become unnecessary complicated. >
On the second thought I can use a buffered channel as a pool of idle workers which is a very simple and clean approach indeed. So thank you for a great hint! -- Andriy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.