Skip to content

Commit 5fc0986

Browse files
committed
review fix
1 parent 8c0e3c0 commit 5fc0986

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

controllers/remote/keyedmutex.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import (
2727
// A second Lock call if the lock is already held for a key returns false.
2828
type keyedMutex struct {
2929
locksMtx sync.Mutex
30-
locks map[client.ObjectKey]bool
30+
locks map[client.ObjectKey]struct{}
3131
}
3232

3333
// newKeyedMutex creates a new keyed mutex ready for use.
3434
func newKeyedMutex() *keyedMutex {
3535
return &keyedMutex{
36-
locks: make(map[client.ObjectKey]bool),
36+
locks: make(map[client.ObjectKey]struct{}),
3737
}
3838
}
3939

@@ -51,7 +51,7 @@ func (k *keyedMutex) TryLock(key client.ObjectKey) bool {
5151
}
5252

5353
// Lock doesn't exist yet, create the lock.
54-
k.locks[key] = true
54+
k.locks[key] = struct{}{}
5555

5656
return true
5757
}
@@ -61,7 +61,6 @@ func (k *keyedMutex) Unlock(key client.ObjectKey) {
6161
k.locksMtx.Lock()
6262
defer k.locksMtx.Unlock()
6363

64-
if k.locks[key] {
65-
delete(k.locks, key)
66-
}
64+
// Remove the lock if it exists.
65+
delete(k.locks, key)
6766
}

0 commit comments

Comments
 (0)