Documentation
¶
Overview ¶
Package waitgroup Based upon sync.WaitGroup waitgroup adds the feature of limiting the maximum number of concurrently started routines.
It could for example be used to start multiples routines querying a database but without sending too much queries in order to not overload the given database.
Created by chenguolin 2019-08-06
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WaitGroup ¶
type WaitGroup struct {
Size int //maximun number of concurrently goroutines
// contains filtered or unexported fields
}
WaitGroup has the same role and close to the same API as the Golang sync.WaitGroup but adds a limit of the amount of goroutines started concurrently.
func New ¶
New creates a WaitGroup. The limit parameter is the maximum amount of goroutines which can be started concurrently.
func (*WaitGroup) Add ¶
func (s *WaitGroup) Add()
Add increments the internal WaitGroup counter. It can be blocking if the limit of spawned goroutines has been reached.