Skip to content

Commit

Permalink
chore(sync): Rename a variable inside sync_getter locking mech for be…
Browse files Browse the repository at this point in the history
…tter readability (#77)
  • Loading branch information
renaynay committed Jul 11, 2023
1 parent b7f7ed0 commit b971a8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sync/sync_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ type syncGetter[H header.Header] struct {
func (sg *syncGetter[H]) Lock() bool {
// the lock construction here ensures only one routine is freed at a time
// while others wait via Rlock
locked := sg.getterLk.TryLock()
if !locked {
acquiredLock := sg.getterLk.TryLock()
if !acquiredLock {
sg.getterLk.RLock()
defer sg.getterLk.RUnlock()
return false
}
sg.isGetterLk.Store(locked)
return locked
sg.isGetterLk.Store(acquiredLock)
return acquiredLock
}

// Unlock unlocks the getter.
Expand Down

0 comments on commit b971a8d

Please sign in to comment.