2023-02-28 10:44:46 +00:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-08-14 03:34:19 +01: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()
|
|
|
|
}
|