alitto / pond

🔘 Minimalistic and High-performance goroutine worker pool written in Go
MIT License
1.43k stars 60 forks source link

Prevent "send on closed channel" panic in purger goroutine #27

Closed alitto closed 2 years ago

alitto commented 2 years ago

Changes included

codecov-commenter commented 2 years ago

Codecov Report

Merging #27 (fe39f93) into master (db6c2ff) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #27   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files           2        2           
  Lines         325      328    +3     
=======================================
+ Hits          324      327    +3     
  Misses          1        1           
Impacted Files Coverage Δ
pond.go 99.67% <100.00%> (+<0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update db6c2ff...fe39f93. Read the comment docs.

chenyahui commented 2 years ago
  1. maybe stop() function forget to close(p.tasks)?
  2. It is possible to wait the purger goroutine exit in stop function?

I implement it in this commit https://github.com/alitto/pond/pull/27/commits/fe39f934963a60e73a75960c64b931584fed70d8 at the same git branch.

Mind to see if this is the right way?

alitto commented 2 years ago

This is great @chenyahui, thank you so much for your contributions :slightly_smiling_face: I'll merge this and release a new patch version (1.7.1)