panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

feat: add a new API `ReleaseTimeout` for the default pool #285

Closed ELchem closed 1 year ago

ELchem commented 1 year ago

name: 'Unblock goPurge and goTicktock in defaultAntsPool' about: ants.Release() calls defaultAntsPool.Release() which leaves goPurge and goTicktock still running in the background. ants.Release() should close the context for goPurge and goTicktock. This can be accomplished by calling defaultAntsPool.ReleaseTimeout(). title: '' labels: '' assignees: ''

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.

goPurge and goTicktock are left on the stack because there is no way to close those methods started by the defaultAntsPool. This PR should add a fix for that.

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

https://github.com/panjf2000/ants/issues/244

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

4. Checklist

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 :tada:

Comparison is base (7be597c) 92.44% compared to head (d2d5227) 92.46%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #285 +/- ## ========================================== + Coverage 92.44% 92.46% +0.01% ========================================== Files 9 9 Lines 768 770 +2 ========================================== + Hits 710 712 +2 Misses 44 44 Partials 14 14 ``` | Flag | Coverage Ξ” | | |---|---|---| | unittests | `92.46% <100.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/panjf2000/ants/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan) | Coverage Ξ” | | |---|---|---| | [ants.go](https://app.codecov.io/gh/panjf2000/ants/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan#diff-YW50cy5nbw==) | `86.36% <100.00%> (+1.36%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.