2
0

Ensure maxSize > 0

This commit is contained in:
Jack Christensen
2019-04-13 18:43:25 -05:00
parent 0395a39c2d
commit e4ced69a3a
2 changed files with 11 additions and 1 deletions
+5 -1
View File
@@ -94,8 +94,12 @@ type Pool struct {
closed bool
}
// NewPool creates a new pool.
// NewPool creates a new pool. Panics if maxSize is less than 1.
func NewPool(constructor Constructor, destructor Destructor, maxSize int32) *Pool {
if maxSize < 1 {
panic("maxSize is less than 1")
}
return &Pool{
cond: sync.NewCond(new(sync.Mutex)),
destructWG: &sync.WaitGroup{},