ants icon indicating copy to clipboard operation
ants copied to clipboard

Submit a task with args to pool

Open icecube092 opened this issue 3 years ago β€’ 3 comments


name: Resolve problem with args capturing

1. Are you opening this pull request for bug-fixs, optimizations or new feature?

New feature.

2. Please describe how these code changes achieve your intention.

Sometimes, we need to call go-routines with args, but by default we have problem - wrong args capturing. And pool has the same problem. This PR resolves this problem.

3. Please link to the relevant issues (if any).

4. Which documentation changes (if any) need to be made/updated because of this PR?

4. Checklist

  • [x] I have squashed all insignificant commits.
  • [x] I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • [x] I have written unit tests and verified that all tests passes (if needed).
  • [x] I have documented feature info on the README (only when this PR is adding a new feature).
  • [ ] (optional) I am willing to help maintain this change if there are issues with it later.

icecube092 avatar May 27 '21 08:05 icecube092

Why bother when we already have https://github.com/panjf2000/ants/blob/master/pool_func.go?

panjf2000 avatar May 29 '21 12:05 panjf2000

It's not the same, for example, i need to have one pool for service without redefining. And sometimes I need to submit task with arguments, which will be captured without this functional. Now, I use an own solution for this. Your functional offers to create a new pool (for one time?).

icecube092 avatar May 30 '21 10:05 icecube092

Sorry, I don't get your point here, would you give me one case where the current API doesn't work and yours does?

panjf2000 avatar May 30 '21 14:05 panjf2000