Add _push_move method for SPSC
This commit is contained in:
1 parent
72c4eb80a2
commit
c8f2c0e06e
1 file changed
+22
-1
+22
-1
@@ -770,7 +770,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Definition of a a QUEUE for Single Produccer / Single Consummer
|
/* Definition of a a QUEUE for Single Producer / Single Consummer
|
||||||
for high bandwidth scenario:
|
for high bandwidth scenario:
|
||||||
* wait-free,
|
* wait-free,
|
||||||
* quite fast
|
* quite fast
|
||||||
@@ -834,6 +834,27 @@ M_C(name, _init)(buffer_t v, size_t size) \
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline bool \
|
static inline bool \
|
||||||
|
M_C(name, _push_move)(buffer_t table, type x) \
|
||||||
|
{ \
|
||||||
|
QUEUEI_SPSC_CONTRACT(table); \
|
||||||
|
unsigned int r = atomic_load_explicit(&table->consoIdx, \
|
||||||
|
memory_order_relaxed); \
|
||||||
|
unsigned int w = atomic_load_explicit(&table->prodIdx, \
|
||||||
|
memory_order_acquire); \
|
||||||
|
if (w-r >= table->size) \
|
||||||
|
return false; \
|
||||||
|
unsigned int i = w & (table->size -1); \
|
||||||
|
if (!BUFFERI_POLICY_P((policy), BUFFER_PUSH_INIT_POP_MOVE)) { \
|
||||||
|
M_DO_MOVE(oplist, table->Tab[i].x, x); \
|
||||||
|
} else { \
|
||||||
|
M_DO_INIT_MOVE(oplist, table->Tab[i].x, x); \
|
||||||
|
} \
|
||||||
|
atomic_store_explicit(&table->prodIdx, w+1, memory_order_release); \
|
||||||
|
QUEUEI_SPSC_CONTRACT(table); \
|
||||||
|
return true; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline bool \
|
||||||
M_C(name, _pop)(type *ptr, buffer_t table) \
|
M_C(name, _pop)(type *ptr, buffer_t table) \
|
||||||
{ \
|
{ \
|
||||||
QUEUEI_SPSC_CONTRACT(table); \
|
QUEUEI_SPSC_CONTRACT(table); \
|
||||||
|
|||||||
Reference in new issue
Block a user