28 lines
416 B
Go
28 lines
416 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
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()
|
|
}
|