[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread Damon Zhao
Got it, thx~ 在 2018年2月7日星期三 UTC+8下午11:25:24,matthe...@gmail.com写道: > > The select already received in that case and is waiting to send, but the > select has to be re-entered for the next receive to happen. > > Matt > > On Wednesday, February 7, 2018 at 9:22:31 AM UTC-6, Damon Zhao wrote: >> >> I

[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread buaa . cch
sorry for misunderstanfing.. this is not a bug... -- 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,

[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread buaa . cch
I think this is a bug, I change the logic of main goroutine and the other goroutine, then the deadlock disappeared ```go package main import ( "fmt" "time" ) var ( source = make(chan int) idle = make(chan int, 1) ) func main() { go func() { for { select { case worker := <-source: idle <-

[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread matthewjuran
The select already received in that case and is waiting to send, but the select has to be re-entered for the next receive to happen. Matt On Wednesday, February 7, 2018 at 9:22:31 AM UTC-6, Damon Zhao wrote: > > I know wrap with a goroutine can fix it. I just wonder why must use an > extra

[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread Damon Zhao
I know wrap with a goroutine can fix it. I just wonder why must use an extra goroutine? 在 2018年2月7日星期三 UTC+8下午11:00:25,matthe...@gmail.com写道: > > Desynchronizing "case idle <- <-source:" fixes it: > > case v := <-source: > go func () { idle <- v }() > > I added a counter to break after a

[go-nuts] Re: Unexpect deadlock on select multi channel ?

2018-02-07 Thread matthewjuran
Desynchronizing "case idle <- <-source:" fixes it: case v := <-source: go func () { idle <- v }() I added a counter to break after a number of loops since it goes infinitely: https://play.golang.org/p/aZbmTKvpxcD Matt On Wednesday, February 7, 2018 at 8:38:41 AM UTC-6, Damon Zhao wrote: >