mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
use STL atomics
This commit is contained in:
parent
a97c4b8078
commit
cd00f8def5
4 changed files with 13 additions and 11 deletions
|
@ -33,11 +33,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <villas/atomic.h>
|
||||
#include <villas/common.h>
|
||||
#include <villas/config.h>
|
||||
|
||||
|
@ -47,13 +48,13 @@ struct memory_type;
|
|||
typedef char cacheline_pad_t[CACHELINE_SIZE];
|
||||
|
||||
struct queue_cell {
|
||||
atomic_size_t sequence;
|
||||
std::atomic<size_t> sequence;
|
||||
off_t data_off; /**< Pointer relative to the queue struct */
|
||||
};
|
||||
|
||||
/** A lock-free multiple-producer, multiple-consumer (MPMC) queue. */
|
||||
struct queue {
|
||||
atomic_state state;
|
||||
std::atomic<enum state> state;
|
||||
|
||||
cacheline_pad_t _pad0; /**< Shared area: all threads read */
|
||||
|
||||
|
@ -62,11 +63,11 @@ struct queue {
|
|||
|
||||
cacheline_pad_t _pad1; /**< Producer area: only producers read & write */
|
||||
|
||||
atomic_size_t tail; /**< Queue tail pointer */
|
||||
std::atomic<size_t> tail; /**< Queue tail pointer */
|
||||
|
||||
cacheline_pad_t _pad2; /**< Consumer area: only consumers read & write */
|
||||
|
||||
atomic_size_t head; /**< Queue head pointer */
|
||||
std::atomic<size_t> head; /**< Queue head pointer */
|
||||
|
||||
cacheline_pad_t _pad3; /**< @todo Why needed? */
|
||||
};
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <villas/atomic.h>
|
||||
#include <villas/signal.h>
|
||||
|
||||
/* Forward declarations */
|
||||
|
@ -67,7 +68,7 @@ struct sample {
|
|||
|
||||
struct vlist *signals; /**< The list of signal descriptors. */
|
||||
|
||||
atomic_int refcnt; /**< Reference counter. */
|
||||
std::atomic<int> refcnt; /**< Reference counter. */
|
||||
ptrdiff_t pool_off; /**< This sample belongs to this memory pool (relative pointer). See sample_pool(). */
|
||||
|
||||
/** All timestamps are seconds / nano seconds after 1.1.1970 UTC */
|
||||
|
|
|
@ -63,7 +63,7 @@ struct shmem_dir {
|
|||
/** Main structure representing the shared memory interface. */
|
||||
struct shmem_int {
|
||||
struct shmem_dir read, write;
|
||||
atomic_int readers, writers, closed;
|
||||
std::atomic<int> readers, writers, closed;
|
||||
};
|
||||
|
||||
/** Open the shared memory objects and retrieve / initialize the shared data structures.
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <jansson.h>
|
||||
#include <complex.h>
|
||||
#include <stdint.h>
|
||||
|
@ -31,8 +33,6 @@
|
|||
/* "I" defined by complex.h collides with a define in OpenSSL */
|
||||
#undef I
|
||||
|
||||
#include <villas/atomic.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vlist;
|
||||
struct node;
|
||||
|
@ -69,7 +69,7 @@ struct signal {
|
|||
|
||||
int enabled;
|
||||
|
||||
atomic_int refcnt; /**< Reference counter. */
|
||||
std::atomic<int> refcnt; /**< Reference counter. */
|
||||
|
||||
enum signal_type type;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue