-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor GoPool and update README.md
- Added comments to all public methods. - Changed public methods and attributes to private where necessary. - Moved Option related code to a new source file. - Updated README.md to include information about Dynamic Worker Adjustment. Signed-off-by: Daniel Hu <[email protected]>
- Loading branch information
1 parent
0aa3f68
commit 758b86d
Showing
4 changed files
with
96 additions
and
56 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package gopool | ||
|
||
import "sync" | ||
|
||
// Option represents an option for the pool. | ||
type Option func(*goPool) | ||
|
||
// WithLock sets the lock for the pool. | ||
func WithLock(lock sync.Locker) Option { | ||
return func(p *goPool) { | ||
p.lock = lock | ||
p.cond = sync.NewCond(p.lock) | ||
} | ||
} | ||
|
||
// WithMinWorkers sets the minimum number of workers for the pool. | ||
func WithMinWorkers(minWorkers int) Option { | ||
return func(p *goPool) { | ||
p.minWorkers = minWorkers | ||
} | ||
} |
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