FAQ
http://blog.golang.org/go-concurrency-patterns-timing-out-and this is the
first result in googling "golang timeout"

select {
case <-ch:
// a read from ch has occurred
case <-timeout:
// the read from ch has timed out
}


but this code is a big trap of goroutine leaking. when read occurred first
the timeout goroutine will leak, and vice versa. I write some code which
reference this artcle, and found and fixed this bug a long time after that.
It would help lots of new comers if this artcle also include code to avoid
goroutine leak.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b0c132a0-13e2-4174-bece-7ee91a6120a0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dan Kortschak at Oct 14, 2013 at 2:47 am
    Why do you think that code leaks a goroutine. If used as shown the
    timeout-sending goroutine returns - the chan is buffered so unless it's
    been sent on before it won't block - and no leak happens.

    --
    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+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1381718873.11795.40.camel%40zoidberg.mbs.adelaide.edu.au.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 14, '13 at 2:29a
activeOct 14, '13 at 2:47a
posts2
users2
websitegolang.org

2 users in discussion

Jarod Liu: 1 post Dan Kortschak: 1 post

People

Translate

site design / logo © 2022 Grokbase