File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
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 ]bool
30
+ locks map [client.ObjectKey ]struct {}
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 ]bool ),
36
+ locks : make (map [client.ObjectKey ]struct {} ),
37
37
}
38
38
}
39
39
@@ -51,7 +51,7 @@ func (k *keyedMutex) TryLock(key client.ObjectKey) bool {
51
51
}
52
52
53
53
// Lock doesn't exist yet, create the lock.
54
- k .locks [key ] = true
54
+ k .locks [key ] = struct {}{}
55
55
56
56
return true
57
57
}
@@ -61,7 +61,6 @@ func (k *keyedMutex) Unlock(key client.ObjectKey) {
61
61
k .locksMtx .Lock ()
62
62
defer k .locksMtx .Unlock ()
63
63
64
- if k .locks [key ] {
65
- delete (k .locks , key )
66
- }
64
+ // Remove the lock if it exists.
65
+ delete (k .locks , key )
67
66
}
You can’t perform that action at this time.
0 commit comments