Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor goroutine pool to use context for graceful exit
- Replace `exitChan` with `context.Context` and `context.CancelFunc` in `goPool` struct. - Create a cancellable context in `NewGoPool` function and store the context and cancel function in `goPool` struct. - Call the cancel function in `Release` method to notify all goroutines to exit. - Listen to the Done channel of the context in `adjustWorkers` method to exit the goroutine when the context is cancelled. Signed-off-by: Daniel Hu <tao.hu@merico.dev>
- Loading branch information