panjf2000 / ants

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

opt: fix the potential goroutine leak after calling `Release()` #287

Closed ELchem closed 1 year ago

ELchem commented 1 year ago

…rom Release method


name: Refactor Release Methods about: Call cleanup functions when Release() is called. title: '' labels: '' assignees: ''

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

Bug fix.

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

By moving stopTicktock and stopPurge into Release() methods from ReleaseTimeout(), these functions will be stopped when Release() is called.

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 (45a0390) 92.46% compared to head (3d949cf) 92.48%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #287 +/- ## ========================================== + Coverage 92.46% 92.48% +0.01% ========================================== Files 9 9 Lines 770 772 +2 ========================================== + Hits 712 714 +2 Misses 44 44 Partials 14 14 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `92.48% <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/287?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan) | Coverage Δ | | |---|---|---| | [pool.go](https://app.codecov.io/gh/panjf2000/ants/pull/287?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan#diff-cG9vbC5nbw==) | `91.25% <100.00%> (+0.03%)` | :arrow_up: | | [pool\_func.go](https://app.codecov.io/gh/panjf2000/ants/pull/287?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andy+Pan#diff-cG9vbF9mdW5jLmdv) | `90.12% <100.00%> (+0.04%)` | :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.