18 #ifndef RAUL_DOUBLE_BUFFER_HPP
19 #define RAUL_DOUBLE_BUFFER_HPP
21 #include "raul/AtomicInt.hpp"
22 #include "raul/AtomicPtr.hpp"
41 : _state(RAUL_DB_READ_WRITE)
44 _read_val = &_vals[0];
48 : _state(RAUL_DB_READ_WRITE)
52 _read_val = &_vals[0];
55 inline T& get()
const {
56 return *_read_val.get();
59 inline bool set(T new_val) {
64 _read_val = &_vals[1];
65 _state = RAUL_DB_WRITE_READ;
75 _read_val = &_vals[0];
76 _state = RAUL_DB_READ_WRITE;
89 RAUL_DB_READ_WRITE = 0,
Atomic integer.
Definition: AtomicInt.hpp:29
bool compare_and_exchange(int old, int val)
Set value to val iff current value is old.
Definition: AtomicInt.hpp:64
Atomic pointer.
Definition: AtomicPtr.hpp:30
Double buffer.
Definition: DoubleBuffer.hpp:37