1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/server/rpc_util.go

33 lines
431 B
Go
Raw Normal View History

2019-11-27 19:12:07 +02:00
package server
import (
"sync"
)
2022-09-30 16:27:07 +02:00
// waitgroup for global management of connections.
2019-11-27 19:12:07 +02:00
type waitGroup struct {
// local waitgroup
lg sync.WaitGroup
// global waitgroup
gg *sync.WaitGroup
}
func (w *waitGroup) Add(i int) {
w.lg.Add(i)
if w.gg != nil {
w.gg.Add(i)
}
}
func (w *waitGroup) Done() {
w.lg.Done()
if w.gg != nil {
w.gg.Done()
}
}
func (w *waitGroup) Wait() {
// only wait on local group
w.lg.Wait()
}