QuantumLibrary
Bloomberg::quantum::Buffer< T, ALLOCATOR > Class Template Reference

Container which allows buffered access to a series of values. Values are pushed-in (written) by a producer(s) and pulled-out (read) by a consumer(s). More...

#include <quantum_buffer.h>

Public Types

using ValueType = T
 Type definition for the contained value. More...
 

Public Member Functions

 Buffer (const ALLOCATOR &alloc=ALLOCATOR())
 Constructor. More...
 
template<class V = T>
BufferStatus push (V &&value)
 Pushes a value at the end of the buffer. This increases the size of the buffer by one. More...
 
BufferStatus pull (T &value)
 Pulls the next value from the buffer. This decreases the size of the buffer by one. More...
 
void close ()
 Close the buffer. Once this method is called, push operations are no longer permitted. Pull operations are permitted until the buffer empties. More...
 
bool isClosed () const
 Indicates if the buffer is closed. More...
 
size_t size () const
 Indicates the number of values stored in the buffer. More...
 
bool empty () const
 Helper function equivalent to size() == 0;. More...
 

Detailed Description

template<class T, class ALLOCATOR>
class Bloomberg::quantum::Buffer< T, ALLOCATOR >

Container which allows buffered access to a series of values. Values are pushed-in (written) by a producer(s) and pulled-out (read) by a consumer(s).

Template Parameters
TType of the contained value.
Warning
This class is not thread safe.

Member Typedef Documentation

◆ ValueType

template<class T, class ALLOCATOR>
using Bloomberg::quantum::Buffer< T, ALLOCATOR >::ValueType = T

Type definition for the contained value.

Constructor & Destructor Documentation

◆ Buffer()

template<class T , class ALLOCATOR>
Bloomberg::quantum::Buffer< T, ALLOCATOR >::Buffer ( const ALLOCATOR &  alloc = ALLOCATOR())

Constructor.

Member Function Documentation

◆ close()

template<class T , class ALLOCATOR >
void Bloomberg::quantum::Buffer< T, ALLOCATOR >::close ( )

Close the buffer. Once this method is called, push operations are no longer permitted. Pull operations are permitted until the buffer empties.

◆ empty()

template<class T , class ALLOCATOR >
bool Bloomberg::quantum::Buffer< T, ALLOCATOR >::empty ( ) const

Helper function equivalent to size() == 0;.

Returns
True if empty, false otherwise.

◆ isClosed()

template<class T , class ALLOCATOR >
bool Bloomberg::quantum::Buffer< T, ALLOCATOR >::isClosed ( ) const

Indicates if the buffer is closed.

◆ pull()

template<class T, class ALLOCATOR >
BufferStatus Bloomberg::quantum::Buffer< T, ALLOCATOR >::pull ( T &  value)

Pulls the next value from the buffer. This decreases the size of the buffer by one.

Parameters
[out]valueReference to the variable which will contain the next valid value if return value is 'DataReceived'.
Returns
Result of the operation. See BufferStatus above for more details.

◆ push()

template<class T , class ALLOCATOR >
template<class V >
BufferStatus Bloomberg::quantum::Buffer< T, ALLOCATOR >::push ( V &&  value)

Pushes a value at the end of the buffer. This increases the size of the buffer by one.

Template Parameters
VType of the contained value. Must be inferred and always equal to T.
Parameters
[in]valueValue pushed into the buffer
Returns
Result of the operation. See BufferStatus above for more details.

◆ size()

template<class T , class ALLOCATOR >
size_t Bloomberg::quantum::Buffer< T, ALLOCATOR >::size ( ) const

Indicates the number of values stored in the buffer.

Returns
Number of values in the buffer.