UNISTDX_BASE_BYTE_BUFFER
class sys::byte_buffer

Byte buffer which uses direct memory allocation for maximum performance.

  • Uses mmap(2) and system calls to bypass memory allocators.
  • Uses mremap(2) to efficiently resize the buffer without copying.
  • Uses madvise(2) to optimise for sequential access and prevent core dumping.

Derived classes
Types
  • using allocator_ptr = std::unique_ptr< allocator >
  • using const_pointer = const void *
  • using pointer = void *
  • using size_type = std::size_t

    Alias to std::size_t.

  • using const_iterator = const value_type *

    Constant pointer to char.

  • using iterator = value_type *

    Pointer to char.

  • using value_type = char

    Alias to char.

Classes
  • class sys::byte_buffer::allocator
Fields
Methods
  • max_size() -> constexpr static size_type

    Returns maximum size a buffer may occupy (theoretical limit).

  • template <class Clock, class Duration>
    read(std::chrono::time_point< Clock, Duration > & t) -> void
  • template <class Clock, class Duration>
    write(std::chrono::time_point< Clock, Duration > t) -> void
  • template <class Rep, class Period>
    read(std::chrono::duration< Rep, Period > & dt) -> void
  • template <class Rep, class Period>
    write(std::chrono::duration< Rep, Period > dt) -> void
  • template <class T>
    read(T & x) -> auto
  • template <class T>
    write(T x) -> auto
  • template <class C, class T, class A>
    read(std::basic_string< C, T, A > & x) -> void
  • template <class C, class T, class A>
    write(const std::basic_string< C, T, A > & x) -> void
  • template <class T>
    read(T & x) -> auto
  • template <class T>
    write(T x) -> auto
  • template <class Source>
    fill(Source & src) -> auto
  • template <class Sink>
    flush(Sink & dst) -> auto
  • clear() -> void
  • compact() -> void
  • bump(size_type n) -> void
  • peek(pointer dst, size_type n) -> void
  • read(pointer dst, size_type n) -> auto
  • write(const_pointer src, size_type n) -> auto
  • flip() -> void
  • order(byte_order rhs) -> void
  • limit(size_type rhs) -> void
  • position(size_type rhs) -> void
  • get_allocator() const -> const allocator *
  • get_allocator() -> allocator *
  • order() const -> byte_order
  • remaining() const -> size_type
  • limit() const -> size_type
  • position() const -> size_type
  • swap(byte_buffer & rhs) -> void

    Swap with rhs.

  • grow() -> void

    Double the buffer size.

    std::length_error
    when maximum size is reached.

    bad_call
    when system error occurs

    See
    mremap(2)
    See
    madvise(2)
  • resize(size_type new_size) -> void

    Resize the buffer preserving its contents.

    bad_call

    See
    mremap(2)
    See
    madvise(2)
  • operator!() const -> bool

    Check if the buffer is valid.

  • operator bool() constexplicit

    Check if the buffer is valid.

  • size() const -> size_type

    Get number of bytes in byte buffer.

  • end() const -> const_iterator

    Get iterator to the end of the container.

  • end() -> iterator

    Get iterator to the end of the container.

  • begin() const -> const_iterator

    Get iterator to the beginning of the container.

  • begin() -> iterator

    Get iterator to the beginning of the container.

  • data() const -> const_iterator

    Get pointer to raw data.

  • data() -> iterator

    Get pointer to raw data.

  • ~byte_buffer()
  • byte_buffer(size_type size, allocator_ptr && allocator = {})explicit

    Construct byte buffer with size size.

    bad_call

    If size is nought, unusable buffer is created and no memory is allocated.

    See
    mmap(2)
    See
    madvise(2)
  • byte_buffer(byte_buffer && rhs)

    Move-constructor.

  • byte_buffer(const byte_buffer & rhs)
  • operator=(const byte_buffer & rhs) -> byte_buffer &
  • byte_buffer(const byte_buffer & rhs, allocator_ptr && allocator)
  • byte_buffer()
swap(byte_buffer & lhs, byte_buffer & rhs) -> void

Overload of std::swap for byte_buffer.

template <class T>
is_basic() -> constexpr bool