FAQ
Hi, I'm trying to improve a concurrency pattern, code here:

http://play.golang.org/p/WJBlS-x_Yt

Could I use buffered a channel to avoid returning nil (L33) ?
At the same time, I'd like to loop on ch instead of names (L38). Is
that possible?

I ran my example with -race and there was no race condition and it
doesn't deadlock (even when I force it to panic L26)

Any help is greatly appreciated.

-- Alfonso

Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Sep 11, 2013 at 5:13 am
    Range over ch, then only put valid values on ch.
    On 11/09/2013, at 14:35, Alfonso Vega-Garcia wrote:

    Hi, I'm trying to improve a concurrency pattern, code here:

    http://play.golang.org/p/WJBlS-x_Yt

    Could I use buffered a channel to avoid returning nil (L33) ?
    At the same time, I'd like to loop on ch instead of names (L38). Is
    that possible?

    I ran my example with -race and there was no race condition and it
    doesn't deadlock (even when I force it to panic L26)

    Any help is greatly appreciated.

    -- Alfonso

    Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Alfonso Vega-Garcia at Sep 11, 2013 at 5:45 am
    Thanks Dave.

    Originally I did so, and got a deadlock, see:

    http://play.golang.org/p/_ZZksLXz9C

    -- Alfonso

    Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com


    On Wed, Sep 11, 2013 at 2:12 PM, Dave Cheney wrote:
    Range over ch, then only put valid values on ch.
    On 11/09/2013, at 14:35, Alfonso Vega-Garcia wrote:

    Hi, I'm trying to improve a concurrency pattern, code here:

    http://play.golang.org/p/WJBlS-x_Yt

    Could I use buffered a channel to avoid returning nil (L33) ?
    At the same time, I'd like to loop on ch instead of names (L38). Is
    that possible?

    I ran my example with -race and there was no race condition and it
    doesn't deadlock (even when I force it to panic L26)

    Any help is greatly appreciated.

    -- Alfonso

    Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Sep 11, 2013 at 5:57 am
    Ugly, but it works, http://play.golang.org/p/BVW-7E17wv
    On Wed, Sep 11, 2013 at 3:45 PM, Alfonso Vega-Garcia wrote:
    Thanks Dave.

    Originally I did so, and got a deadlock, see:

    http://play.golang.org/p/_ZZksLXz9C

    -- Alfonso

    Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com


    On Wed, Sep 11, 2013 at 2:12 PM, Dave Cheney wrote:
    Range over ch, then only put valid values on ch.
    On 11/09/2013, at 14:35, Alfonso Vega-Garcia wrote:

    Hi, I'm trying to improve a concurrency pattern, code here:

    http://play.golang.org/p/WJBlS-x_Yt

    Could I use buffered a channel to avoid returning nil (L33) ?
    At the same time, I'd like to loop on ch instead of names (L38). Is
    that possible?

    I ran my example with -race and there was no race condition and it
    doesn't deadlock (even when I force it to panic L26)

    Any help is greatly appreciated.

    -- Alfonso

    Alfonso Vega-Garcia | Software Engineer | vegacom at gmail.com

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Roger peppe at Sep 11, 2013 at 8:34 am

    On 11 September 2013 06:57, Dave Cheney wrote:
    Ugly, but it works, http://play.golang.org/p/BVW-7E17wv
    I think that on balance I prefer the original here.

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 11, '13 at 4:36a
activeSep 11, '13 at 8:34a
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase