Bryan Mill's presentation on go concurrency patterns is well worth watching all the way through: https://www.youtube.com/watch?v=5zXAHh5tJqQ
There are lots of code snippets which are directly relevant to what you're trying to do, e.g. from 20:48 is a queue with Get, and 21:59 a queue with GetMany. He starts with the traditional semaphore approach and then shows a much cleaner and simpler way of doing it. The biggest revelation I got was: instead of having a data structure protected by a mutex, you can stuff a data structure into a one-element buffered channel. When you need to use it: pop it out, modify it, push it back in. Very easy to reason about. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7b198a7b-daaf-435b-930f-bb318dd838e3n%40googlegroups.com.