Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor GoPool for thread safety and efficiency
- Added mutex and condition variable to GoPool struct for thread safety. - Replaced time.Sleep with condition variable Wait in dispatch method to avoid busy waiting. - Added locking and unlocking around operations that modify workerStack to ensure thread safety. - Signaled condition variable after pushing a worker back to the stack. - Ensured all workers are done before releasing resources in Release method. - Commented out pool.Release() in BenchmarkGoPool test. - Changed the number of workers in BenchmarkGoPool test from 10000 to 1e4 for readability. Signed-off-by: Daniel Hu <[email protected]>
- Loading branch information