mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-06 23:30:29 +00:00
chore(poller): Add poller package
Signed-off-by: Bo-Yi Wu <[email protected]>
This commit is contained in:
1 parent
4d7ef95d40
commit
0b885c5e5f
5 files changed
+107
-2
No files matched your search
@@ -0,0 +1,24 @@
|
||||
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()
|
||||
}
|
||||
Reference in new issue
Block a user