mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
properly define atomic state for queue
This commit is contained in:
parent
292e846bf8
commit
b21a017cc2
3 changed files with 14 additions and 4 deletions
|
@ -33,4 +33,14 @@ enum state {
|
|||
STATE_LOADED = 4, /* alias for STATE_STARTED used by plugins */
|
||||
STATE_STOPPED = 5,
|
||||
STATE_UNLOADED = 5 /* alias for STATE_STARTED used by plugins */
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef __cpluscplus
|
||||
|
||||
typedef std::atomic_int atomic_state;
|
||||
|
||||
#else
|
||||
|
||||
typedef _Atomic enum state atomic_state;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,7 @@ struct queue_cell {
|
|||
struct queue {
|
||||
cacheline_pad_t _pad0; /**< Shared area: all threads read */
|
||||
|
||||
atomic_size_t state;
|
||||
atomic_state state;
|
||||
|
||||
struct memtype *mem;
|
||||
size_t buffer_mask;
|
||||
|
|
|
@ -188,8 +188,8 @@ int queue_pull_many(struct queue *q, void *ptr[], size_t cnt)
|
|||
|
||||
int queue_close(struct queue *q)
|
||||
{
|
||||
size_t expected = STATE_INITIALIZED;
|
||||
if (atomic_compare_exchange_weak_explicit(&q->state, &expected, STATE_STOPPED, memory_order_relaxed, memory_order_relaxed)) {
|
||||
int expected = STATE_INITIALIZED;
|
||||
if (atomic_compare_exchange_weak_explicit(&q->state, &expected, STATE_STOPPED, memory_order_relaxed, memory_order_relaxed))
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue