🍹 Reduce the threshold time of cleaning up goroutines

This commit is contained in:
Andy Pan 2019-02-22 23:25:35 +08:00
parent 96348a39f5
commit e9f5d0c06f
1 changed files with 3 additions and 2 deletions

View File

@ -33,7 +33,7 @@ const (
DefaultAntsPoolSize = math.MaxInt32 DefaultAntsPoolSize = math.MaxInt32
// DefaultCleanIntervalTime is the interval time to clean up goroutines. // DefaultCleanIntervalTime is the interval time to clean up goroutines.
DefaultCleanIntervalTime = 5 DefaultCleanIntervalTime = 1
) )
var ( var (
@ -64,10 +64,11 @@ var (
// new connections if WorkerFunc is CPU-bound. // new connections if WorkerFunc is CPU-bound.
return 1 return 1
}() }()
defaultAntsPool, _ = NewPool(DefaultAntsPoolSize)
) )
// Init a instance pool when importing ants. // Init a instance pool when importing ants.
var defaultAntsPool, _ = NewPool(DefaultAntsPoolSize)
// Submit submits a task to pool. // Submit submits a task to pool.
func Submit(task func()) error { func Submit(task func()) error {