act_runner/poller/thread.go
Bo-Yi Wu 0b885c5e5f chore(poller): Add poller package
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2022-11-24 15:36:56 +08:00

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()
}