mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-21 20:27:17 +03:00
0b885c5e5f
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
24 lines
325 B
Go
24 lines
325 B
Go
package poller
|
|
|
|
import "sync"
|
|
|
|
type routineGroup struct {
|
|
waitGroup sync.WaitGroup
|
|
}
|
|
|
|
func newRoutineGroup() *routineGroup {
|
|
return new(routineGroup)
|
|
}
|
|
|
|
func (g *routineGroup) Run(fn func()) {
|
|
g.waitGroup.Add(1)
|
|
|
|
go func() {
|
|
defer g.waitGroup.Done()
|
|
fn()
|
|
}()
|
|
}
|
|
|
|
func (g *routineGroup) Wait() {
|
|
g.waitGroup.Wait()
|
|
}
|