Efficient way of waiting until all goroutine workers have completed processing #369
Unanswered
sandykellagher
asked this question in
Q&A
Replies: 1 comment
-
|
You can call Alternatively, you can define a wrapper that integrates |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We are using ants as a convenient Goroutine worker pool, that allows us to make requests in parallel with a limit on the maximum number of parallel Goroutines at any one time.
In some cases, it would be helpful to know when the set of workers that we have fired off via Submit() calls have all completed their processing. By analogy, using a simple sync.WaitGroup wg, we can call wg.Wait().
At the moment, the only answer I can see from the ants API is to poll the Running() method (eg every 10 ms) until it returns zero. But that seems a bit clumsy.
I guess we could still use a sync.WaitGroup in combination with ants, eg
But it'd be more elegant if I could just call a poolWait() function
Beta Was this translation helpful? Give feedback.
All reactions