Skip to content

Commit

Permalink
DynamicBoundedQueue: Round threshold up to avoid threshold 0
Browse files Browse the repository at this point in the history
Summary: Ensure that threshold is not 0, otherwise when capacity < 10, threshold is 0, which can lead to consumers never transferring credit to producers.

Differential Revision: D26791831

fbshipit-source-id: 741bcf17de18198e43471d4b36d98c79288652fb
  • Loading branch information
magedm authored and facebook-github-bot committed Mar 4, 2021
1 parent 626e5ca commit 63c11c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion folly/concurrency/DynamicBoundedQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class DynamicBoundedQueue {
// Calculation of threshold to move credits in bulk from consumers
// to producers
constexpr Weight threshold(Weight capacity) const noexcept {
return capacity / 10;
return (capacity + 9) / 10;
}

// Functions called frequently by producers
Expand Down

0 comments on commit 63c11c4

Please sign in to comment.