internal sync.RWMutex
unlockActions []func()
m map[uintptr]struct{}
+ // Currently unlocking, defers should not occur?
+ unlocking bool
}
func (me *lockWithDeferreds) Lock() {
func (me *lockWithDeferreds) Unlock() {
defer me.internal.Unlock()
+ me.unlocking = true
startLen := len(me.unlockActions)
for i := range startLen {
me.unlockActions[i]()
}
me.unlockActions = me.unlockActions[:0]
clear(me.unlockActions)
+ me.unlocking = false
}
func (me *lockWithDeferreds) RLock() {
}
func (me *lockWithDeferreds) Defer(action func()) {
+ if me.unlocking {
+ panic("defer called while unlocking")
+ }
me.unlockActions = append(me.unlockActions, action)
}