Re: [go-nuts] Why is this code runs sequentially?

2018-12-08 Thread Jérôme LAFORGE
By the way, the readers of channel must not close a channel. Only writer can 
closes it to indicate to reader that channel is closed and nothing can be read 
from it. You can let channel opens (there is no resource leak), it will be 
garbage collected anyway.

-- 
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, visit https://groups.google.com/d/optout.


Re: [go-nuts] Why is this code runs sequentially?

2018-12-08 Thread Alex Dvoretskiy
Got it! Thanks!

On Friday, December 7, 2018 at 2:34:38 AM UTC-8, rog wrote:
>
> You want to run it concurrently, but you also need the results in order so 
> that you can concatenate them together in the right order (I'm assuming). 
> Something like this would do the trick: 
> https://play.golang.org/p/lMI8rmEBJ-d
>
> On Thu, 6 Dec 2018 at 23:40, Alex Dvoretskiy  > wrote:
>
>> Hi Golangnuts,
>>
>> I'm trying to run SignerCrc32() concurently, but instead it runs 
>> sequentially. Can you explain why?
>>
>> https://play.golang.org/p/l5A3tBSqfs1
>>
>> -- 
>> 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 .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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, visit https://groups.google.com/d/optout.


Re: [go-nuts] Why is this code runs sequentially?

2018-12-07 Thread roger peppe
You want to run it concurrently, but you also need the results in order so
that you can concatenate them together in the right order (I'm assuming).
Something like this would do the trick:
https://play.golang.org/p/lMI8rmEBJ-d

On Thu, 6 Dec 2018 at 23:40, Alex Dvoretskiy 
wrote:

> Hi Golangnuts,
>
> I'm trying to run SignerCrc32() concurently, but instead it runs
> sequentially. Can you explain why?
>
> https://play.golang.org/p/l5A3tBSqfs1
>
> --
> 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, visit https://groups.google.com/d/optout.
>

-- 
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, visit https://groups.google.com/d/optout.


Re: [go-nuts] Why is this code runs sequentially?

2018-12-06 Thread Burak Serdar
On Thu, Dec 6, 2018 at 4:40 PM Alex Dvoretskiy  wrote:
>
> Hi Golangnuts,
>
> I'm trying to run SignerCrc32() concurently, but instead it runs 
> sequentially. Can you explain why?

You are running it concurrently, but you're waiting for the result to arrive.

SignerCrc32 runs in a separate goroutine. It takes it 1 second to
return the result. During that time, the Worker for loop is waiting to
read from tmpChan. When SignerCrc32 returns, the result is written to
tmpChan, for loop iterates once, creates another goroutine, and starts
waiting to read from tmpChan again, which will come in one second.




>
> https://play.golang.org/p/l5A3tBSqfs1
>
> --
> 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, visit https://groups.google.com/d/optout.

-- 
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, visit https://groups.google.com/d/optout.