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