Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Robert Solomon
I don't know how to change that. I had an issue w/ the main routine ending before some of the worker routines were done so I saw incomplete results. How do I tweak my logic so that I don't need a WaitGroup? I forgot about my platform specific code. Here is the rest of that, that is in a

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread rob
Looks like you're right. I changed the order of the defer statement and now I'm not getting that error. Interesting that I never saw any file errors. Thanks --rob solomon On 10/2/22 14:46, Matthew Zimmerman wrote: First reason I notice, if there's an error opening your file, wg.Done() is

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Andrew Harris
I think Matthew is correct about the immediate source of the deadlock - because the defer is placed too late in the body of grepFile(), the deferred decrement of the waitGroup isn't run on an os.Open() error. I had the same impression as Jan, I think there is a concern here: the condition for

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread rob
When I do that, I get this error: panic: sync: negative WaitGroup number On 10/2/22 14:39, Jan Mercl wrote: On Sun, Oct 2, 2022 at 7:36 PM Robert Solomon wrote: https://go.dev/play/p/gIVVLsiTqod I believe wg.Add on line 125 is too late. I think it needs to be moved before the go

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Matthew Zimmerman
First reason I notice, if there's an error opening your file, wg.Done() is never called. On Sun, Oct 2, 2022, 1:36 PM Robert Solomon wrote: > https://go.dev/play/p/gIVVLsiTqod > > I'm trying to understand concurrency, so I modified a small routine I came > across quite a while ago. It's a grep

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 7:36 PM Robert Solomon wrote: > https://go.dev/play/p/gIVVLsiTqod I believe wg.Add on line 125 is too late. I think it needs to be moved before the go statement on line 108. Not tested. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Robert Solomon
https://go.dev/play/p/gIVVLsiTqod I'm trying to understand concurrency, so I modified a small routine I came across quite a while ago. It's a grep command, but since I have its source, I am trying to understand its concurrency. My problem is that when there are more than about 1800 files to be