Or preferably with a better explanation than my admittedly poor title:I have two channels that are related. The idea is that messages to one channel cause a large update, while messages to another cause smaller updates that may or may not affect the larger one. While it's not required that all waiting smaller updates are processed before the next larger updates, it's ideal. So I devised a scheme to make sure that all currently waiting smaller updates (if any exist) process before the big update happens.
A sillier example with strings:
It's... ugly, I was wondering if anybody had any suggestions. In my particular case, it's important that reads from both channels happen in a single OS Thread (which means they have to be in the same goroutine locked with LockOSThread()), but I'm interested in more general solutions too, since I think a nicer solution could probably be done with two goroutines.
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The package implements a pool of go routines that are dedicated to processing jobs posted into the pool. It maintains two queues, a normal processing queue and a priority queue. Jobs placed in the priority queue will be processed ahead of pending jobs in the normal queue.
If priority is not required, consider using my workpool package. It is faster and more efficient.
Read the following blog post for more information
http://www.goinggo.net/2013/05/thread-pooling-in-go-programming.html