qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::allocator::pipe< T > Class Template Reference

Extensible buffer optimized for performance. More...

#include <pipe.h>

Inheritance diagram for qb::allocator::pipe< T >:
Collaboration diagram for qb::allocator::pipe< T >:

Public Member Functions

void swap (pipe &rhs) noexcept
 Swaps content with another buffer.
template<typename _It>
pipeput (_It begin, _It const &end)
 Adds elements from an iterator range.
pipeput (T const *data, std::size_t const size)
 Adds elements from an array.
template<typename U>
pipeoperator<< (U &&rhs) noexcept
 Adds an element to the buffer (operator <<)
pipe< char > & put (qb::compression::deflate::to_compress &)
 Template specialization for putting compressed data into a character pipe.
pipe< char > & put (qb::compression::deflate::to_uncompress &)
 Template specialization for putting decompressed data into a character pipe.
pipe< char > & put (qb::compression::gzip::to_compress &)
 Template specialization for putting gzip compressed data into a character pipe.
pipe< char > & put (qb::compression::gzip::to_uncompress &)
 Template specialization for putting gzip decompressed data into a character pipe.
pipe< char > & put (const json &c)
pipe< char > & put (const char &c)
pipe< char > & put (const unsigned char &c)
pipe< char > & put (const char *const &c)
pipe< char > & put (std::string const &str)
pipe< char > & put (std::string_view const &str)
pipe< char > & put (pipe< char > const &rhs)
Public Member Functions inherited from qb::allocator::base_pipe< T >
 base_pipe ()
 Default constructor.
 base_pipe (base_pipe const &rhs)
 Copy constructor.
 base_pipe (base_pipe &&rhs) noexcept
 Move constructor.
base_pipeoperator= (base_pipe const &rhs)
 Copy assignment operator.
base_pipeoperator= (base_pipe &&rhs) noexcept
 Move assignment operator.
 ~base_pipe ()
 Destructor.
std::size_t capacity () const noexcept
 Returns the total capacity of the buffer.
T * data () const noexcept
 Returns a pointer to the buffer data.
T * begin () const noexcept
 Returns a pointer to the first valid element.
T * end () const noexcept
 Returns a pointer just after the last valid element.
const T * cbegin () const noexcept
 Returns a constant pointer to the first valid element.
const T * cend () const noexcept
 Returns a constant pointer just after the last valid element.
std::size_t size () const noexcept
 Returns the number of valid elements in the buffer.
void resize (std::size_t new_size)
 Resizes the buffer.
void free_front (std::size_t const size) noexcept
 Frees elements at the beginning of the buffer.
void free_back (std::size_t const size) noexcept
 Frees elements at the end of the buffer.
void reset (std::size_t const begin) noexcept
 Resets the buffer to a specific position.
void reset () noexcept
 Completely resets the buffer.
void clear () noexcept
 Clears the buffer content (alias for reset)
bool empty () const noexcept
 Checks if the buffer is empty.
void free (std::size_t const size) noexcept
 Frees a specified number of elements.
auto * allocate_back (std::size_t const size)
 Allocates space at the end of the buffer.
template<typename U, typename... _Init>
U & allocate_back (_Init &&...init)
 Allocates and constructs an object of type U at the end of the buffer.
template<typename U, typename... _Init>
U & allocate_size (std::size_t const size, _Init &&...init)
 Allocates space with a custom size and constructs an object.
auto allocate (std::size_t const size)
 Allocates space at the beginning or end of the buffer.
template<typename U, typename... _Init>
U & allocate (_Init &&...init)
 Allocates space and constructs an object.
template<typename U>
U & recycle_back (U const &data)
 Copies an object to the end of the buffer.
template<typename U>
U & recycle_back (U const &data, std::size_t const size)
 Copies data to the end of the buffer.
template<typename U>
U & recycle (U const &data)
 Copies an object to the beginning or end of the buffer.
template<typename U>
U & recycle (U const &data, std::size_t const size)
 Copies data to the beginning or end of the buffer.
void reorder () noexcept
 Reorganizes the buffer to consolidate free space.
void flush () const noexcept
 Flushes the buffer (synchronization operation, no-op in this class)
void reserve (std::size_t const size)
 Reserves space in the buffer.

Additional Inherited Members

Protected Attributes inherited from qb::allocator::base_pipe< T >
std::size_t _begin
 Index of first valid element.
std::size_t _end
 Index just after the last valid element.
bool _flag_front
 Indicates if the last allocation was at the beginning.
std::size_t _capacity
 Total buffer capacity.
std::size_t _factor
 Buffer expansion factor.
T * _data
 Buffer data.

Detailed Description

template<typename T>
class qb::allocator::pipe< T >

Extensible buffer optimized for performance.

Implements an extensible buffer aligned on cache lines for optimal performance in multithreaded contexts.

Template Parameters
TType of elements stored in the buffer

Member Function Documentation

◆ swap()

template<typename T>
void qb::allocator::pipe< T >::swap ( pipe< T > & rhs)
inlinenoexcept

Swaps content with another buffer.

Parameters
rhsOther buffer for the swap

◆ put() [1/6]

template<typename T>
template<typename _It>
pipe & qb::allocator::pipe< T >::put ( _It begin,
_It const & end )
inline

Adds elements from an iterator range.

Template Parameters
_ItIterator type
Parameters
beginBegin iterator
endEnd iterator
Returns
Reference to this buffer

◆ put() [2/6]

template<typename T>
pipe & qb::allocator::pipe< T >::put ( T const * data,
std::size_t const size )
inline

Adds elements from an array.

Parameters
dataPointer to the data
sizeNumber of elements
Returns
Reference to this buffer

◆ operator<<()

template<typename T>
template<typename U>
pipe & qb::allocator::pipe< T >::operator<< ( U && rhs)
inlinenoexcept

Adds an element to the buffer (operator <<)

Template Parameters
UType of element to add
Parameters
rhsElement to add
Returns
Reference to this buffer

◆ put() [3/6]

Template specialization for putting compressed data into a character pipe.

This specialization allows direct use of deflate compression within a pipe's put operation.

Parameters
infoCompression parameters and results structure
Returns
Reference to this pipe for method chaining

◆ put() [4/6]

Template specialization for putting decompressed data into a character pipe.

This specialization allows direct use of deflate decompression within a pipe's put operation.

Parameters
infoDecompression parameters and results structure
Returns
Reference to this pipe for method chaining

◆ put() [5/6]

Template specialization for putting gzip compressed data into a character pipe.

This specialization allows direct use of gzip compression within a pipe's put operation.

Parameters
infoCompression parameters and results structure
Returns
Reference to this pipe for method chaining

◆ put() [6/6]

Template specialization for putting gzip decompressed data into a character pipe.

This specialization allows direct use of gzip decompression within a pipe's put operation.

Parameters
infoDecompression parameters and results structure
Returns
Reference to this pipe for method chaining