go-zero/core/syncx/barrier.go
2020-07-26 17:09:05 +08:00

14 lines
155 B
Go

package syncx
import "sync"
type Barrier struct {
lock sync.Mutex
}
func (b *Barrier) Guard(fn func()) {
b.lock.Lock()
defer b.lock.Unlock()
fn()
}