select {
case highVal := <- high:
case lowVal := <- low:
        if len(high) > 0 {
            for len(high) > 0 {
                highVal := <- high
            }
        }       
        // process lowVal
}



On Tuesday, July 24, 2012 at 5:16:16 AM UTC+8, Erwin Driessens wrote:
>
> Hello,
>
> i wonder how to implement channel priorities nicely. Say there are two 
> channels, one with a higher priority than the other, and a goroutine 
> waiting for incoming data on these channels. I have read that select picks 
> a random case when multiple channels are ready. I thought of nesting 
> selects: putting the lower priority select in the default case of the 
> higher priority select, and have the default case of the inner (low 
> priority) select do nothing. This leads to a kind of busy wait loop. I 
> could call a short sleep, but that still isn't very clean. Is there a 
> better way?
>
> Why aren't the select cases evaluated in order?  
>

-- 
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.

Reply via email to