github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/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     Copyright Ronak Software Group 2020
    14  */
    15  
    16  var waitGroupPool sync.Pool
    17  
    18  func AcquireWaitGroup() *sync.WaitGroup {
    19  	wgv := waitGroupPool.Get()
    20  	if wgv == nil {
    21  		return &sync.WaitGroup{}
    22  	}
    23  
    24  	return wgv.(*sync.WaitGroup)
    25  }
    26  
    27  func ReleaseWaitGroup(wg *sync.WaitGroup) {
    28  	waitGroupPool.Put(wg)
    29  }