![]() |
glbinding
3.3.0.0
A C++ binding for the OpenGL API, generated using the gl.xml specification.
|
A threadsafe queue with a single insertion and multiple extraction points. More...
#include <glbinding-aux/RingBuffer.h>
Public Types | |
using | SizeType = unsigned int |
Numeric type employed for indices, sizes and distances. | |
using | TailIdentifier = unsigned int |
Identifier type for tails. | |
Public Member Functions | |
RingBuffer (SizeType maxSize) | |
Constructor. | |
void | resize (SizeType newSize) |
Resize buffer. | |
T | nextHead (bool &available) const |
Retrieve element beyond current head. | |
bool | push (T &&entry) |
Add an element to the buffer, if possible. | |
bool | push (T &entry) |
Add an element to the buffer, if possible. | |
TailIdentifier | addTail () |
Add a new tail to the buffer. | |
void | removeTail (TailIdentifier key) |
Remove a tail from the buffer. | |
const std::vector< T >::const_iterator | cbegin (TailIdentifier key) const |
Retrieve the iterator for a tail. | |
bool | valid (TailIdentifier key, const typename std::vector< T >::const_iterator &it) const |
Check if iterator is valid. | |
const std::vector< T >::const_iterator | next (TailIdentifier key, const typename std::vector< T >::const_iterator &it) |
Advance the iterator of a tail. | |
SizeType | size (TailIdentifier key) |
Calculate distance between tail and head. | |
SizeType | maxSize () const |
Query maximum size. | |
SizeType | size () const |
Query current size. | |
bool | isFull () const |
Query if buffer is full. | |
bool | isEmpty () const |
Query if buffer is empty. | |
Protected Member Functions | |
SizeType | next (SizeType current) const |
Calculate following index in internal buffer. | |
bool | isFull (SizeType nextHead) const |
Check if head can advance. | |
SizeType | lastTail () const |
Determine last (furthest behind) index still in use. | |
SizeType | size (SizeType head, SizeType tail) const |
Calculate size of range between two indices. | |
Protected Attributes | |
std::vector< T > | m_buffer |
Internal buffer. | |
SizeType | m_size |
Size of buffer. | |
std::atomic< SizeType > | m_head |
Index of head (newest element) | |
std::map< TailIdentifier, std::atomic< SizeType > > | m_tails |
Map (identifier->index) of tails. | |
A threadsafe queue with a single insertion and multiple extraction points.
T | Data type stored within the buffer |
using glbinding::aux::RingBuffer< T >::SizeType = unsigned int |
Numeric type employed for indices, sizes and distances.
using glbinding::aux::RingBuffer< T >::TailIdentifier = unsigned int |
Identifier type for tails.
glbinding::aux::RingBuffer< T >::RingBuffer | ( | SizeType | maxSize | ) |
Constructor.
[in] | maxSize | Maximum size for the buffer |
References glbinding::aux::RingBuffer< T >::m_buffer, and glbinding::aux::RingBuffer< T >::m_size.
void glbinding::aux::RingBuffer< T >::resize | ( | SizeType | newSize | ) |
Resize buffer.
[in] | newSize | New maximum size for the buffer |
T glbinding::aux::RingBuffer< T >::nextHead | ( | bool & | available | ) | const |
Retrieve element beyond current head.
[out] | available | true if buffer has available space, false otherwise |
bool glbinding::aux::RingBuffer< T >::push | ( | T && | entry | ) |
Add an element to the buffer, if possible.
[in] | entry | Element to add |
true
if the element could be added, false
otherwise bool glbinding::aux::RingBuffer< T >::push | ( | T & | entry | ) |
Add an element to the buffer, if possible.
[in] | entry | Element to add |
true
if the element could be added, false
otherwise RingBuffer< T >::TailIdentifier glbinding::aux::RingBuffer< T >::addTail | ( | ) |
Add a new tail to the buffer.
void glbinding::aux::RingBuffer< T >::removeTail | ( | TailIdentifier | key | ) |
Remove a tail from the buffer.
[in] | key | Identifier for the tail to be removed |
const std::vector< T >::const_iterator glbinding::aux::RingBuffer< T >::cbegin | ( | TailIdentifier | key | ) | const |
Retrieve the iterator for a tail.
[in] | key | Identifier for the tail |
bool glbinding::aux::RingBuffer< T >::valid | ( | TailIdentifier | key, |
const typename std::vector< T >::const_iterator & | it ) const |
Check if iterator is valid.
[in] | key | Identifier for the tail |
[in] | it | Iterator to check |
true
if iterator is valid, false
otherwise const std::vector< T >::const_iterator glbinding::aux::RingBuffer< T >::next | ( | TailIdentifier | key, |
const typename std::vector< T >::const_iterator & | it ) |
Advance the iterator of a tail.
[in] | key | Identifier for the tail |
[in] | it | Iterator to return in case of failure |
RingBuffer< T >::SizeType glbinding::aux::RingBuffer< T >::size | ( | TailIdentifier | key | ) |
Calculate distance between tail and head.
[in] | key | Identifier for tail |
RingBuffer< T >::SizeType glbinding::aux::RingBuffer< T >::maxSize | ( | ) | const |
Query maximum size.
RingBuffer< T >::SizeType glbinding::aux::RingBuffer< T >::size | ( | ) | const |
Query current size.
bool glbinding::aux::RingBuffer< T >::isFull | ( | ) | const |
Query if buffer is full.
true
if buffer is full, false
otherwise bool glbinding::aux::RingBuffer< T >::isEmpty | ( | ) | const |
Query if buffer is empty.
true
if buffer is empty, false
otherwise
|
protected |
Calculate following index in internal buffer.
[in] | current | Base index |
|
protected |
Check if head can advance.
[in] | nextHead | Index to check |
true
if nextHead is referenced by a tail, false
otherwise
|
protected |
Determine last (furthest behind) index still in use.
|
protected |
Calculate size of range between two indices.
[in] | head | End of range |
[in] | tail | Start of range |
|
protected |
Internal buffer.
Referenced by glbinding::aux::RingBuffer< T >::RingBuffer().
|
protected |
Size of buffer.
Referenced by glbinding::aux::RingBuffer< T >::RingBuffer().
|
protected |
Index of head (newest element)
|
protected |
Map (identifier->index) of tails.