package torrent
-import "sync"
+import "github.com/anacrolix/sync"
// Runs deferred actions on Unlock. Note that actions are assumed to be the results of changes that
// would only occur with a write lock at present. The race detector should catch instances of defers
}
func (me *lockWithDeferreds) Unlock() {
- for _, a := range me.unlockActions {
- a()
+ unlockActions := me.unlockActions
+ for i := 0; i < len(unlockActions); i += 1 {
+ unlockActions[i]()
}
- me.unlockActions = me.unlockActions[:0]
+ me.unlockActions = unlockActions[:0]
me.internal.Unlock()
}