Documentation ¶
Index ¶
- type GoLock
- func (g *GoLock) Lock()
- func (g *GoLock) LockFunc(fn func(parameters ...any), parameters ...any)
- func (g *GoLock) RLock()
- func (g *GoLock) RLockFunc(fn func(parameters ...any), parameters ...any)
- func (g *GoLock) RUnlock()
- func (g *GoLock) Unlock()
- func (g *GoLock) WLock()
- func (g *GoLock) WLockFunc(fn func(parameters ...any), parameters ...any)
- func (g *GoLock) WUnlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoLock ¶
type GoLock struct { Mutex sync.Mutex // 读锁时不能写,写锁时不能读取 MuteRW sync.RWMutex //读写互斥锁,并发读取,单一写入。读多写少性能会好 }
RWMutex 也称为读写互斥锁,读写互斥锁就是读取/写入互相排斥的锁。它可以由任意数量的读取操作的 goroutine 或单个写入操作的 goroutine 持有。 读写互斥锁 RWMutex 类型有五个方法,Lock,Unlock,Rlock,RUnlock 和 RLocker。其中,RLocker 返回一个 Locker 接口, 该接口通过调用 rw.RLock 和 rw.RUnlock 来实现 Lock 和 Unlock 方法。 不能拷贝锁
Click to show internal directories.
Click to hide internal directories.