Ocean
Ocean::Network::BufferQueue Class Reference

This class implements a thread-safe buffer queue. More...

Public Member Functions

void push (const void *data, const size_t size)
 Pushes a new buffer to the queue. More...
 
void push (Buffer &&data)
 Pushes a new buffer to the queue. More...
 
Buffer pop ()
 Pops a buffer from the queue. More...
 
void clear ()
 Clears the buffer queue. More...
 
size_t size () const
 Returns the number of buffers in this queue. More...
 
bool isEmpty () const
 Returns whether this queue holds no buffers. More...
 

Protected Types

typedef std::vector< uint8_t > Buffer
 Definition of a vector holding bytes. More...
 
typedef std::deque< BufferQueue
 Definition of a double-ended queue holding buffers. More...
 

Protected Attributes

Queue queue_
 The internal buffer queue. More...
 
Lock lock_
 The buffer lock. More...
 

Detailed Description

This class implements a thread-safe buffer queue.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8_t> Ocean::Network::BufferQueue::Buffer
protected

Definition of a vector holding bytes.

◆ Queue

typedef std::deque<Buffer> Ocean::Network::BufferQueue::Queue
protected

Definition of a double-ended queue holding buffers.

Member Function Documentation

◆ clear()

void Ocean::Network::BufferQueue::clear ( )
inline

Clears the buffer queue.

◆ isEmpty()

bool Ocean::Network::BufferQueue::isEmpty ( ) const
inline

Returns whether this queue holds no buffers.

Returns
True, if so

◆ pop()

BufferQueue::Buffer Ocean::Network::BufferQueue::pop ( )
inline

Pops a buffer from the queue.

Returns
The buffer, if any

◆ push() [1/2]

void Ocean::Network::BufferQueue::push ( Buffer &&  data)
inline

Pushes a new buffer to the queue.

Parameters
dataThe data to push, will be moved

◆ push() [2/2]

void Ocean::Network::BufferQueue::push ( const void *  data,
const size_t  size 
)
inline

Pushes a new buffer to the queue.

Parameters
dataThe data to push, will be copied, can be nullptr if 'size == 0'
sizeThe number of bytes to copy, with range [0, infinity)

◆ size()

size_t Ocean::Network::BufferQueue::size ( ) const
inline

Returns the number of buffers in this queue.

Returns
The number of buffers

Field Documentation

◆ lock_

Lock Ocean::Network::BufferQueue::lock_
mutableprotected

The buffer lock.

◆ queue_

Queue Ocean::Network::BufferQueue::queue_
protected

The internal buffer queue.


The documentation for this class was generated from the following file: