2023-02-28 04:44:46 -06:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-08-13 21:34:19 -05:00
|
|
|
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()
|
|
|
|
}
|