eckit::CountedBuffer class

A buffer that can be shared and is thread-safe Note that this buffer, once shared should be for read-only shared-access (at the moment) because access is not controlled by locking, only allocation and deallocation

Base classes

class Buffer
Simple class to implement memory buffers.
class Counted

Constructors, destructors, conversion operators

CountedBuffer(size_t size)
operator char*()
operator const char*() const
operator void*()
operator const void*() const

Public functions

auto data() -> void*
auto data() const -> const void*
auto size() const -> size_t
void zero()
Zero content of buffer.
void resize(size_t newSize, bool preserveData = false)
void copy(const void*, size_t size, size_t pos = 0)
void attach() const
void detach() const
auto count() const -> size_t
void lock() const
void unlock() const

Function documentation

eckit::CountedBuffer::operator char*()

eckit::CountedBuffer::operator const char*() const

eckit::CountedBuffer::operator void*()

eckit::CountedBuffer::operator const void*() const

void* eckit::CountedBuffer::data()

const void* eckit::CountedBuffer::data() const

size_t eckit::CountedBuffer::size() const

Returns buffer size in bytes

Returns size of the buffer in bytes Note: The actual allocation held by this buffer may be larger if the buffer has been resized with 'preserveData' set to a smaller size than before.

void eckit::CountedBuffer::zero()

Zero content of buffer.

void eckit::CountedBuffer::resize(size_t newSize, bool preserveData = false)

Resizes the buffer to newSize. When 'preserveData' is set:

  • Buffer will still hold the data contained before resize() was called.
  • If 'newSize' is smaller than the current 'size' the data will be truncated. With unset 'preserveData' the contents of the buffer will be discarded.

void eckit::CountedBuffer::copy(const void*, size_t size, size_t pos = 0)

Copy data of given size (bytes) into buffer at given position

void eckit::CountedBuffer::attach() const

void eckit::CountedBuffer::detach() const

size_t eckit::CountedBuffer::count() const

void eckit::CountedBuffer::lock() const

void eckit::CountedBuffer::unlock() const

This website is beyond its original expiry date and the content may be out of date. The site owner has been notified and may choose to extend the expiry date and remove this banner. If you have any questions about this, please visit our support portal.