go-zero/core/syncx/barrier.go

14 lines
155 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package syncx
import "sync"
type Barrier struct {
lock sync.Mutex
}
func (b *Barrier) Guard(fn func()) {
b.lock.Lock()
defer b.lock.Unlock()
fn()
}