github.com/clubpay/ronykit/kit@v0.14.4-0.20240515065620-d0dace45cbc7/utils/pools/waitgroup.go (about)

     1  package pools
     2  
     3  import (
     4  	"sync"
     5  )
     6  
     7  /*
     8     Creation Time: 2019 - Oct - 03
     9     Created by:  (ehsan)
    10     Maintainers:
    11        1.  Ehsan N. Moosa (E2)
    12     Auditor: Ehsan N. Moosa (E2)
    13  */
    14  
    15  var waitGroupPool sync.Pool
    16  
    17  func AcquireWaitGroup() *sync.WaitGroup {
    18  	wgv := waitGroupPool.Get()
    19  	if wgv == nil {
    20  		return &sync.WaitGroup{}
    21  	}
    22  
    23  	return wgv.(*sync.WaitGroup) //nolint:forcetypeassert
    24  }
    25  
    26  func ReleaseWaitGroup(wg *sync.WaitGroup) {
    27  	waitGroupPool.Put(wg)
    28  }