Re: [go-nuts] Priority cases in select?

2017-01-25 Thread Jakub Labath
Glad someone mentioned reflect.Select. Implemented simple round robin solution with a timeout case (if no data is available at all) using just that . To add to some priority would be just be a matter of setting the channel/cases to nil after several writes, rather than just after one like I do

Re: [go-nuts] Priority cases in select?

2017-01-25 Thread Wim Lewis
On Jan 25, 2017, at 8:00 AM, 'Axel Wagner' via golang-nuts wrote: > It's also a feature rabbit-hole. I'd predict, that next up, someone who > experiences starvation wants to add weighted scheduling ("give this case an > 80% chance of succeeding and this other case 20%, so that eventually eith

Re: [go-nuts] Priority cases in select?

2017-01-25 Thread T L
On Wednesday, January 25, 2017 at 10:14:49 PM UTC+8, Jan Mercl wrote: > > On Wed, Jan 25, 2017 at 2:14 PM T L > > wrote: > > > sometimes, I do want one case on a select block get selected even if > there are multiple unblocked cases. > > For example, I don't want the dataCh case is selected if

Re: [go-nuts] Priority cases in select?

2017-01-25 Thread Jan Mercl
On Wed, Jan 25, 2017 at 2:14 PM T L wrote: > sometimes, I do want one case on a select block get selected even if there are multiple unblocked cases. > For example, I don't want the dataCh case is selected if the stopCh and the timer channel are unblocked: select { case <-priorit

[go-nuts] Priority cases in select?

2017-01-25 Thread T L
sometimes, I do want one case on a select block get selected even if there are multiple unblocked cases. For example, I don't want the dataCh case is selected if the stopCh and the timer channel are unblocked: select { case <- stopCh: return case value := <-dataCh: } select { case <- time.A