Skip to content

Commit

Permalink
Fix lockfree queue size and full check (#203)
Browse files Browse the repository at this point in the history
Signed-off-by: Coldwings <coldwings@me.com>
  • Loading branch information
Coldwings authored and beef9999 committed Oct 26, 2023
1 parent ae41915 commit 70a21cc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/lockfree_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ struct Capacity_2expN<0> {
template <>
struct Capacity_2expN<1> : public Capacity_2expN<0> {};

template <>
struct Capacity_2expN<2> : public Capacity_2expN<0> {};

struct PauseBase {};

struct CPUPause : PauseBase {
Expand Down Expand Up @@ -136,7 +139,7 @@ class LockfreeRingQueueBase {
bool check_empty(size_t h, size_t t) const { return h == t; }

bool check_full(size_t h, size_t t) const {
return check_mask_equal(h, t + 1);
return h != t && check_mask_equal(h, t);
}

size_t idx(size_t x) const { return x & mask; }
Expand Down

0 comments on commit 70a21cc

Please sign in to comment.