Ocean
Loading...
Searching...
No Matches
Ocean::Network::BufferQueue Class Reference

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

#include <BufferQueue.h>

Public Member Functions

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

Protected Types

using Buffer = std::vector<uint8_t>
 Definition of a vector holding bytes.
using Queue = std::deque<Buffer>
 Definition of a double-ended queue holding buffers.

Protected Attributes

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

Detailed Description

This class implements a thread-safe buffer queue.

Member Typedef Documentation

◆ Buffer

using Ocean::Network::BufferQueue::Buffer = std::vector<uint8_t>
protected

Definition of a vector holding bytes.

◆ Queue

using Ocean::Network::BufferQueue::Queue = std::deque<Buffer>
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: