129 : MAX_THREADS(max_threads), BUF_LEN( max_threads + 2),
135 write_ptr = &data[1];
150 virtual DataType
Get()
const {DataType cache;
Get(cache);
return cache; }
159 virtual void Get( DataType& pull )
const 169 if ( reading != read_ptr )
176 pull = reading->data;
186 virtual void Set(
const DataType& push )
197 write_ptr->data = push;
201 while (
oro_atomic_read( &write_ptr->next->counter ) != 0 || write_ptr->next == read_ptr )
203 write_ptr = write_ptr->next;
204 if (write_ptr == wrote_ptr)
209 read_ptr = wrote_ptr;
210 write_ptr = write_ptr->next;
215 for (
unsigned int i = 0; i < BUF_LEN-1; ++i) {
216 data[i].data = sample;
217 data[i].next = &data[i+1];
219 data[BUF_LEN-1].data = sample;
220 data[BUF_LEN-1].next = &data[0];
const unsigned int MAX_THREADS
The maximum number of threads.
DataObjectLockFree(const T &initial_value=T(), unsigned int max_threads=2)
#define oro_atomic_inc(v)
DataBuf *volatile VolPtrType
#define oro_atomic_set(v, i)
virtual DataType Get() const
virtual void Get(DataType &pull) const
This DataObject is a Lock-Free implementation, such that reads and writes can happen concurrently wit...
#define oro_atomic_dec(v)
virtual void Set(const DataType &push)
const unsigned int BUF_LEN
virtual void data_sample(const DataType &sample)
#define oro_atomic_read(v)