Fix issue for SPSC queue:
computing the number of elements in the queue is not reliable enough as we can get more than than the size of the queue.
This commit is contained in:
1 parent
4fbffc4788
commit
08f44845ce
1 file changed
+2
-2
+2
-2
@@ -664,7 +664,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
|
|||||||
memory_order_relaxed); \
|
memory_order_relaxed); \
|
||||||
unsigned int w = atomic_load_explicit(&table->prodIdx, \
|
unsigned int w = atomic_load_explicit(&table->prodIdx, \
|
||||||
memory_order_acquire); \
|
memory_order_acquire); \
|
||||||
if (w-r == table->size) \
|
if (w-r >= table->size) \
|
||||||
return false; \
|
return false; \
|
||||||
unsigned int i = w & (table->size -1); \
|
unsigned int i = w & (table->size -1); \
|
||||||
if (!BUFFERI_POLICY_P((policy), BUFFER_PUSH_INIT_POP_MOVE)) { \
|
if (!BUFFERI_POLICY_P((policy), BUFFER_PUSH_INIT_POP_MOVE)) { \
|
||||||
@@ -729,7 +729,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
|
|||||||
static inline bool \
|
static inline bool \
|
||||||
M_C(name, _full_p)(buffer_t v) \
|
M_C(name, _full_p)(buffer_t v) \
|
||||||
{ \
|
{ \
|
||||||
return M_C(name, _size)(v) == v->size; \
|
return M_C(name, _size)(v) >= v->size; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline void \
|
static inline void \
|
||||||
|
|||||||
Reference in new issue
Block a user