C/C++ API Reference
Loading...
Searching...
No Matches
pw::multibuf::v1_adapter::MultiBufAllocator Class Referenceabstract

Overview

Interface for allocating v1_adapter::MultiBuf objects that mimics v1::MultiBufAllocator.

This type can be used as a drop-in replacement for v1::MultiBufAllocator while migrating to using pw_multibuf/v2.

Unlike v1::MultiBufAllocator, this interface always allocates contiguous memory.

Inheritance diagram for pw::multibuf::v1_adapter::MultiBufAllocator:
pw::multibuf::v1_adapter::SimpleAllocator

Public Member Functions

 MultiBufAllocator (MultiBufAllocator &)=delete
 MultiBufAllocator is not copyable or movable.
 
MultiBufAllocatoroperator= (MultiBufAllocator &)=delete
 
 MultiBufAllocator (MultiBufAllocator &&)=delete
 
MultiBufAllocatoroperator= (MultiBufAllocator &&)=delete
 
std::optional< MultiBufAllocate (size_t min_size)
 
std::optional< MultiBufAllocate (size_t min_size, size_t desired_size)
 
std::optional< MultiBufAllocateContiguous (size_t min_size)
 
std::optional< MultiBufAllocateContiguous (size_t min_size, size_t desired_size)
 
std::optional< size_t > GetBackingCapacity ()
 

Private Member Functions

virtual std::optional< MultiBufDoAllocate (size_t min_size, size_t desired_size, bool contiguous)=0
 
virtual std::optional< size_t > DoGetBackingCapacity ()=0
 

Member Function Documentation

◆ Allocate() [1/2]

std::optional< MultiBuf > pw::multibuf::v1_adapter::MultiBufAllocator::Allocate ( size_t  min_size)
inline

Attempts to allocate a MultiBuf of exactly size bytes.

Memory allocated by an arbitrary MultiBufAllocator does not provide any alignment requirements, preferring instead to allow the allocator maximum flexibility for placing regions (especially discontiguous regions).

Return values
``MultiBuf``if the allocation was successful.
``nullopt_t``if the memory is not currently available.

◆ Allocate() [2/2]

std::optional< MultiBuf > pw::multibuf::v1_adapter::MultiBufAllocator::Allocate ( size_t  min_size,
size_t  desired_size 
)
inline

Attempts to allocate a MultiBuf of exactly size bytes.

Memory allocated by an arbitrary MultiBufAllocator does not provide any alignment requirements, preferring instead to allow the allocator maximum flexibility for placing regions (especially discontiguous regions).

Return values
``MultiBuf``if the allocation was successful.
``nullopt_t``if the memory is not currently available.

◆ AllocateContiguous() [1/2]

std::optional< MultiBuf > pw::multibuf::v1_adapter::MultiBufAllocator::AllocateContiguous ( size_t  min_size)
inline

Attempts to allocate a contiguous MultiBuf of exactly size bytes.

Memory allocated by an arbitrary MultiBufAllocator does not provide any alignment requirements, preferring instead to allow the allocator maximum flexibility for placing regions (especially discontiguous regions).

Return values
``MultiBuf``with a single Chunk if the allocation was successful.
``nullopt_t``if the memory is not currently available.

◆ AllocateContiguous() [2/2]

std::optional< MultiBuf > pw::multibuf::v1_adapter::MultiBufAllocator::AllocateContiguous ( size_t  min_size,
size_t  desired_size 
)
inline

Attempts to allocate a contiguous MultiBuf of exactly size bytes.

Memory allocated by an arbitrary MultiBufAllocator does not provide any alignment requirements, preferring instead to allow the allocator maximum flexibility for placing regions (especially discontiguous regions).

Return values
``MultiBuf``with a single Chunk if the allocation was successful.
``nullopt_t``if the memory is not currently available.

◆ DoAllocate()

virtual std::optional< MultiBuf > pw::multibuf::v1_adapter::MultiBufAllocator::DoAllocate ( size_t  min_size,
size_t  desired_size,
bool  contiguous 
)
privatepure virtual

Attempts to allocate a MultiBuf of exactly size bytes.

Memory allocated by an arbitrary MultiBufAllocator does not provide any alignment requirements, preferring instead to allow the allocator maximum flexibility for placing regions (especially discontiguous regions).

Return values
``MultiBuf``if the allocation was successful.
``nullopt_t``if the memory is not currently available.

Implemented in pw::multibuf::v1_adapter::SimpleAllocator.

◆ DoGetBackingCapacity()

virtual std::optional< size_t > pw::multibuf::v1_adapter::MultiBufAllocator::DoGetBackingCapacity ( )
privatepure virtual

Returns the total amount of memory provided by this object.

This is an optional method. Some memory providers may not have an easily defined capacity, e.g. the system allocator.

Return values
thetotal memory if known.
``nullopt_t``if the total memory is not knowable.

Implemented in pw::multibuf::v1_adapter::SimpleAllocator.

◆ GetBackingCapacity()

std::optional< size_t > pw::multibuf::v1_adapter::MultiBufAllocator::GetBackingCapacity ( )
inline

Returns the total amount of memory provided by this object.

This is an optional method. Some memory providers may not have an easily defined capacity, e.g. the system allocator.

Return values
thetotal memory if known.
``nullopt_t``if the total memory is not knowable.

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