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.
◆ 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
-
| the | total 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
-
| the | total memory if known. |
| ``nullopt_t`` | if the total memory is not knowable. |
The documentation for this class was generated from the following file:
- pw_multibuf/v1_adapter/public/pw_multibuf/v1_adapter/allocator.h