5 // Runs deferred actions on Unlock. Note that actions are assumed to be the results of changes that
6 // would only occur with a write lock at present. The race detector should catch instances of defers
7 // without the write lock being held.
8 type lockWithDeferreds struct {
10 unlockActions []func()
13 func (me *lockWithDeferreds) Lock() {
17 func (me *lockWithDeferreds) Unlock() {
18 for _, a := range me.unlockActions {
21 me.unlockActions = me.unlockActions[:0]
25 func (me *lockWithDeferreds) RLock() {
29 func (me *lockWithDeferreds) RUnlock() {
33 func (me *lockWithDeferreds) Defer(action func()) {
34 me.unlockActions = append(me.unlockActions, action)