On Dec 6, 2019, at 8:32 AM, Egon Kocjan <eko...@gmail.com> wrote:
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/82830a5d-2bd8-4324-890e-9ae7f5f0fbaf%40googlegroups.com.
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> 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/chandemo1_1.go: easy with en extra goroutine (takes 1.2s for million ints)2_1.go: nice but completely wrong2_2.go: better but still deadlocks2_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 youEgon
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.
On Dec 6, 2019, at 9:30 AM, Egon Kocjan <eko...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/bdc57eb0-b26f-4364-87fb-241b0807e8ae%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/75d69b4e-4fb7-4f62-8011-f21e2a4c294a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/75d69b4e-4fb7-4f62-8011-f21e2a4c294a%40googlegroups.com.
On Dec 7, 2019, at 2:38 AM, Egon Kocjan <eko...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8b87adcc-2249-402c-b34c-20df5013860a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8b87adcc-2249-402c-b34c-20df5013860a%40googlegroups.com.
On Dec 8, 2019, at 12:11 AM, Egon Kocjan <eko...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3b9bb722-d43f-4e70-8384-dc17cdec6090%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3b9bb722-d43f-4e70-8384-dc17cdec6090%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4a176af0-74bb-49b5-ae4d-d8714c7bc46d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4a176af0-74bb-49b5-ae4d-d8714c7bc46d%40googlegroups.com.
My demo is based on a real problem in our code. The issue here is that I cannot paste proprietary code and it's large and complex anyway. I distilled the problem to a bidi-communication coding exercise. The "go srv" in the real code is an external process with stdin and stdout with a simple line based protocol. Both pipes are then presented as go channels: one line = one channel message.
This is a bit off-topic now, but coincidentally we will have another talk (probably by my work colleague) that is related to one of your approaches from the talk:// Glob finds all items with names matching pattern// and sends them on the returned channel.// It closes the channel when all items have been sent.func Glob(pattern string) <-chan Item {
We had a bug where due to panic+recover the channel consumer stopped reading from the channel prematurely and the producer deadlocked the entire process. I will argue that for exposed public API, sql-like defer Close / Next / Scan is safer than raw channels.
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/1LZzZ0lE6ZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/31041bab-56be-4b91-978f-c22fb8f5a19f%40googlegroups.com.
This is a bit off-topic now, but coincidentally we will have another talk (probably by my work colleague) that is related to one of your approaches from the talk:// Glob finds all items with names matching pattern// and sends them on the returned channel.// It closes the channel when all items have been sent.func Glob(pattern string) <-chan Item {We had a bug where due to panic+recover the channel consumer stopped reading from the channel prematurely and the producer deadlocked the entire process. I will argue that for exposed public API, sql-like defer Close / Next / Scan is safer than raw channels.It seems that you didn't read/watch the whole talk, or even the whole section of the talk?(I made exactly that point on slides 24–36. The asynchronous examples are the pattern to be rethought, not the final result!