mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-12-28 11:58:20 +01:00
25 lines
325 B
Go
25 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()
|
||
|
}
|