milvus/internal/datanode/io_pool.go
yah01 167581c08a
Refine Pool to improve the ease of use (#22412)
Signed-off-by: yah01 <yang.cen@zilliz.com>
2023-02-27 18:07:48 +08:00

25 lines
493 B
Go

package datanode
import (
"sync"
"github.com/milvus-io/milvus/internal/util/concurrency"
)
var ioPool *concurrency.Pool
var ioPoolInitOnce sync.Once
func initIOPool() {
capacity := Params.DataNodeCfg.IOConcurrency.GetAsInt()
if capacity > 32 {
capacity = 32
}
// error only happens with negative expiry duration or with negative pre-alloc size.
ioPool = concurrency.NewPool(capacity)
}
func getOrCreateIOPool() *concurrency.Pool {
ioPoolInitOnce.Do(initIOPool)
return ioPool
}