github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/pools/gopool/goroutine.go (about)

     1  package gopool
     2  
     3  import (
     4  	"github.com/panjf2000/ants/v2"
     5  )
     6  
     7  /*
     8     Creation Time: 2020 - Dec - 29
     9     Created by:  (ehsan)
    10     Maintainers:
    11        1.  Ehsan N. Moosa (E2)
    12     Auditor: Ehsan N. Moosa (E2)
    13     Copyright Ronak Software Group 2020
    14  */
    15  
    16  var goPool *ants.Pool
    17  
    18  func Go(f func()) {
    19  	_ = goPool.Submit(f)
    20  }
    21  
    22  func init() {
    23  	p, err := ants.NewPool(-1)
    24  	if err != nil {
    25  		panic(err)
    26  	}
    27  	goPool = p
    28  }