File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,13 @@ import (
27
27
// A second Lock call if the lock is already held for a key returns false.
28
28
type keyedMutex struct {
29
29
locksMtx sync.Mutex
30
- locks map [client.ObjectKey ]* sync. Mutex
30
+ locks map [client.ObjectKey ]bool
31
31
}
32
32
33
33
// newKeyedMutex creates a new keyed mutex ready for use.
34
34
func newKeyedMutex () * keyedMutex {
35
35
return & keyedMutex {
36
- locks : make (map [client.ObjectKey ]* sync. Mutex ),
36
+ locks : make (map [client.ObjectKey ]bool ),
37
37
}
38
38
}
39
39
@@ -50,10 +50,8 @@ func (k *keyedMutex) TryLock(key client.ObjectKey) bool {
50
50
return false
51
51
}
52
52
53
- // Lock doesn't exist yet, create and lock the lock.
54
- l := & sync.Mutex {}
55
- k .locks [key ] = l
56
- l .Lock ()
53
+ // Lock doesn't exist yet, create the lock.
54
+ k .locks [key ] = true
57
55
58
56
return true
59
57
}
@@ -63,8 +61,7 @@ func (k *keyedMutex) Unlock(key client.ObjectKey) {
63
61
k .locksMtx .Lock ()
64
62
defer k .locksMtx .Unlock ()
65
63
66
- if l , ok := k .locks [key ]; ok {
67
- l .Unlock ()
64
+ if k .locks [key ] {
68
65
delete (k .locks , key )
69
66
}
70
67
}
You can’t perform that action at this time.
0 commit comments