Skip to content

Commit

Permalink
Increment size before putting in the queue
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott committed Jan 27, 2020
1 parent 4b58b94 commit 6aaa413
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/queue/bounded_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ func (q *BoundedQueue) Produce(item interface{}) bool {
return false
}

q.size.Add(1)
select {
case *q.items <- item:
q.size.Add(1)
return true
default:
// should not happen, as overflows should have been captured earlier
q.size.Sub(1)
if q.onDroppedItem != nil {
q.onDroppedItem(item)
}
Expand Down

0 comments on commit 6aaa413

Please sign in to comment.