Skip to content

Commit

Permalink
inflight: correct delete functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Johansson committed Sep 3, 2019
1 parent 91042f7 commit 2c52433
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions inflight/inflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ type syncU64set struct {
}

func (s *syncU64set) Delete(v uint64) bool {
s.mu.RLock()
if !s.pks.Has(v) {
s.mu.RUnlock()
return false
}
s.mu.RUnlock()
s.mu.Lock()
_, found := s.pks.Pop2()
s.mu.Unlock()
return found
defer s.mu.Unlock()
if !s.pks.Has(v) {
// double check
return false
}
s.pks.Remove(v)
return true
}

func (s *syncU64set) AddIfNotPresent(v uint64) bool {
Expand Down

0 comments on commit 2c52433

Please sign in to comment.