package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Jan 30, 2021
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 4
Opens a new window with list of known importers.
README
¶
go lang goroutine concurrency limiter
builds

example
limit the number of concurrent go routines to 10:
limit := limiter.New(10)
for i := 0; i < 1000; i++ {
limit.Execute(func() {
// do some work
})
}
limit.Wait()
Documentation
¶
type Limiter chan struct{}
Limiter ...
New instanciates a new Limiter
limit: the max number of goroutines running at a time
func (c Limiter) Execute(job func())
Execute will queue jobs, thanks to how channels work
job: the function you want to be run on this limiter
Wait waits that all jobs are done
Wait have to be called only once per instance
Source Files
¶
Click to show internal directories.
Click to hide internal directories.