A simple first-fit MultiBufAllocator
.
More...
#include <simple_allocator.h>
|
class | internal::LinkedRegionTracker |
|
A simple first-fit MultiBufAllocator
.
◆ SimpleAllocator()
pw::multibuf::SimpleAllocator::SimpleAllocator |
( |
ByteSpan |
data_area, |
|
|
pw::allocator::Allocator & |
metadata_alloc, |
|
|
size_t |
alignment = 1 |
|
) |
| |
Creates a new SimpleAllocator
.
- Parameters
-
[in] | data_area | The region to use for storing chunk memory. |
[in] | metadata_alloc | The allocator to use for metadata tracking the in-use regions. This allocator must be thread-safe if the resulting buffers may travel to another thread. SynchronizedAllocator can be used to create a thread-safe allocator from a non-thread-safe allocator. |
[in] | alignment | The alignment to use. All chunks allocated by this allocator will start aligned with the specified alignment. The alignment can change if the prefix Chunk methods are used. The supplied data_area must be aligned (both start and end) to the specified alignment. Defaults to 1. |
◆ DoAllocate()
pw::Result< MultiBuf > pw::multibuf::SimpleAllocator::DoAllocate |
( |
size_t |
min_size, |
|
|
size_t |
desired_size, |
|
|
ContiguityRequirement |
contiguity_requirement |
|
) |
| |
|
finalprivatevirtual |
Attempts to allocate a MultiBuf
of at least min_size
bytes and at most desired_size
bytes.
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: Returns the buffer if the allocation was successful.
*
* RESOURCE_EXHAUSTED: Insufficient memory is available currently.
*
* OUT_OF_RANGE: This amount of memory will not become possible to
* allocate in the future, or this allocator is unable to signal via
* ``MoreMemoryAvailable`` (this will result in asynchronous allocations
* failing immediately on OOM).
*
*
Implements pw::multibuf::MultiBufAllocator.
◆ DoGetBackingCapacity()
std::optional< size_t > pw::multibuf::SimpleAllocator::DoGetBackingCapacity |
( |
| ) |
|
|
inlinefinalprivatevirtual |
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. |
Implements pw::multibuf::MultiBufAllocator.
The documentation for this class was generated from the following file: