barrier.go 155 B

12345678910111213
  1. package syncx
  2. import "sync"
  3. type Barrier struct {
  4. lock sync.Mutex
  5. }
  6. func (b *Barrier) Guard(fn func()) {
  7. b.lock.Lock()
  8. defer b.lock.Unlock()
  9. fn()
  10. }