32 #ifndef _GLIBCXX_PARALLEL_QUEUE_H
33 #define _GLIBCXX_PARALLEL_QUEUE_H 1
40 #define _GLIBCXX_VOLATILE volatile
70 this->max_size = max_size;
71 base =
new T[max_size];
85 lcas_t former_borders = borders;
86 int former_front, former_back;
87 decode2(former_borders, former_front, former_back);
88 *(base + former_front % max_size) = t;
89 #if _GLIBCXX_ASSERTIONS
91 _GLIBCXX_PARALLEL_ASSERT(((former_front + 1) - former_back)
102 int former_front, former_back;
104 decode2(borders, former_front, former_back);
105 while (former_front > former_back)
112 t = *(base + (former_front - 1) % max_size);
116 decode2(borders, former_front, former_back);
126 int former_front, former_back;
128 decode2(borders, former_front, former_back);
129 while (former_front > former_back)
136 t = *(base + former_back % max_size);
140 decode2(borders, former_front, former_back);
147 #undef _GLIBCXX_VOLATILE
uint64 sequence_index_t
Unsigned integer to index elements. The total number of elements for each algorithm must fit into thi...
Compatibility layer, mostly concerned with atomic operations. This file is a GNU parallel extension t...
Double-ended queue of bounded size, allowing lock-free atomic access. push_front() and pop_front() mu...
#define _GLIBCXX_VOLATILE
Decide whether to declare certain variable volatile in this file.
bool pop_back(T &t)
Pops one element from the queue at the front end. Must not be called concurrently with pop_front()...
bool compare_and_swap(volatile T *ptr, T comparand, T replacement)
Compare *ptr and comparand. If equal, let *ptr=replacement and return true, return false otherwise...
GNU parallel code for public use.
Sequential helper functions. This file is a GNU parallel extension to the Standard C++ Library...
void push_front(const T &t)
Pushes one element into the queue at the front end. Must not be called concurrently with pop_front()...
Basic types and typedefs. This file is a GNU parallel extension to the Standard C++ Library...
lcas_t encode2(int a, int b)
Encode two integers into one __gnu_parallel::lcas_t.
~RestrictedBoundedConcurrentQueue()
Destructor. Not to be called concurrent, of course.
void decode2(lcas_t x, int &a, int &b)
Decode two integers from one __gnu_parallel::lcas_t.
T fetch_and_add(volatile T *ptr, T addend)
Add a value to a variable, atomically.
int64 lcas_t
Longest compare-and-swappable integer type on this platform.
bool pop_front(T &t)
Pops one element from the queue at the front end. Must not be called concurrently with pop_front()...
RestrictedBoundedConcurrentQueue(sequence_index_t max_size)
Constructor. Not to be called concurrent, of course.