mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
14 lines
155 B
Go
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()
|
|
}
|