There are goroutines in the examples of course, just a single goroutine per bidi channel seems hard. By contrast, I've worked with actor systems before and they are perfectly fine with a single fiber.
On Friday, December 6, 2019 at 3:38:20 PM UTC+1, Robert Engels wrote: > > Channels are designed to be used with multiple go routines - if you’re not > you are doing something wrong. > > On Dec 6, 2019, at 8:32 AM, Egon Kocjan <eko...@gmail.com <javascript:>> > wrote: > > > Hello > > I'm preparing a short talk about Go channels and select. More > specifically, I want to show what not to do. I chose a bidirectional > communication channel implementation, because it seems to be a common base > for a lot of problems but hard to implement correctly without using any > extra goroutines. All the code is here: https://github.com/egonk/chandemo > > 1_1.go: easy with en extra goroutine (takes 1.2s for million ints) > 2_1.go: nice but completely wrong > 2_2.go: better but still deadlocks > 2_3.go: correct but ugly and slow (takes more than 2s for million ints) > 2_4.go: correct and a bit faster but still ugly (1.8s for million ints) > > So my question: is there a better way of doing it with just nested for and > select and no goroutines? Basically, what would 2_5.go look like? > > Thank you > Egon > > -- > 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 golan...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/82830a5d-2bd8-4324-890e-9ae7f5f0fbaf%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/82830a5d-2bd8-4324-890e-9ae7f5f0fbaf%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- 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/bdc57eb0-b26f-4364-87fb-241b0807e8ae%40googlegroups.com.