github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xsync/mutex.go (about) 1 package xsync 2 3 import ( 4 "sync" 5 ) 6 7 type Mutex struct { //nolint:gocritic 8 sync.Mutex 9 } 10 11 func (l *Mutex) WithLock(f func()) { 12 l.Lock() 13 defer l.Unlock() 14 15 f() 16 } 17 18 type RWMutex struct { //nolint:gocritic 19 sync.RWMutex 20 } 21 22 func (l *RWMutex) WithLock(f func()) { 23 l.Lock() 24 defer l.Unlock() 25 26 f() 27 } 28 29 func (l *RWMutex) WithRLock(f func()) { 30 l.RLock() 31 defer l.RUnlock() 32 33 f() 34 }