Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement condition variable in worker pool
- Added a condition variable to the Pool struct to manage the pool. - Created a NewPool function to initialize the pool with the condition variable. - Modified the Submit method to wait if the pool is at capacity before adding a new worker. - Added a signal to the worker's run method to notify the condition variable when a worker is done. - Added a broadcast in the Pool's Release method to notify all waiting goroutines when the pool is released. Signed-off-by: Daniel Hu <tao.hu@merico.dev>
- Loading branch information
1 parent
aa15268
commit 678a72b
Showing
2 changed files
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters