func (workerPool *NonBlockingWorkerPool) get() *ants.Pool {
	workerPool.initOnce.Do(func() {
		if newPool, err := ants.NewPool(runtime.GOMAXPROCS(0), ants.WithNonblocking(true)); err != nil {
			panic(err)
		} else {
			workerPool.pool = newPool
		}
	})
	return workerPool.pool
}
Internal utility function that initiates and returns the pool.
package async
import (
	"fmt"
	"runtime"
	"runtime/debug"
	"sync"
	"github.com/panjf2000/ants/v2"
	"github.com/iotaledger/hive.go/typeutils"
)
type NonBlockingWorkerPool struct {
	pool         *ants.Pool
	stopped      typeutils.AtomicBool
	tasksWg      sync.WaitGroup
	initOnce     sync.Once
	shutdownOnce sync.Once
}
func (workerPool *NonBlockingWorkerPool) Submit(f func()) bool {
	if workerPool.stopped.IsSet() {
		return false
	}
	workerPool.tasksWg.Add(1)
	if antsErr := workerPool.get().Submit(func() {
		defer func() {
			if r := recover(); r != nil {
				workerPool.tasksWg.Done()
				fmt.Printf("recovered from panic in WorkerPool: %s %s", r, debug.Stack())
			}
		}()
		f()
		workerPool.tasksWg.Done()
	}); antsErr != nil && antsErr != ants.ErrPoolOverload {
		panic(antsErr)
	} else {
		if antsErr == nil {
			return true
		} else {
			workerPool.tasksWg.Done()
			return false
		}
	}
}
func (workerPool *NonBlockingWorkerPool) Capacity() int {
	if workerPool.stopped.IsSet() {
		return 0
	}
	return workerPool.get().Cap()
}
func (workerPool *NonBlockingWorkerPool) Tune(capacity int) *NonBlockingWorkerPool {
	if workerPool.stopped.IsSet() {
		return workerPool
	}
	workerPool.get().Tune(capacity)
	return workerPool
}
func (workerPool *NonBlockingWorkerPool) IdleWorkers() int {
	if workerPool.stopped.IsSet() {
		return 0
	}
	return workerPool.get().Free()
}
func (workerPool *NonBlockingWorkerPool) RunningWorkers() int {
	if workerPool.stopped.IsSet() {
		return 0
	}
	return workerPool.get().Running()
}
func (workerPool *NonBlockingWorkerPool) Shutdown() {
	workerPool.shutdownOnce.Do(func() {
		workerPool.stopped.Set()
		if workerPool.pool != nil {
			go workerPool.pool.Release()
		}
	})
}
func (workerPool *NonBlockingWorkerPool) ShutdownGracefully() {
	workerPool.shutdownOnce.Do(func() {
		workerPool.stopped.Set()
		workerPool.tasksWg.Wait()
		if workerPool.pool != nil {
			go workerPool.pool.Release()
		}
	})
}