Pigweed
Loading...
Searching...
No Matches
pw::allocator::ChunkPool Class Reference

#include <chunk_pool.h>

Public Member Functions

 ChunkPool (ByteSpan region, const Layout &layout)
 
- Public Member Functions inherited from pw::allocator::Pool
constexpr Pool (const Capabilities &capabilities, const Layout &layout)
 
const Layoutlayout () const
 
void * Allocate ()
 
- Public Member Functions inherited from pw::Deallocator
const Capabilitiescapabilities () const
 
bool HasCapability (Capability capability) const
 Returns whether a given capabilityis enabled for this object.
 
void Deallocate (void *ptr)
 
void Deallocate (void *ptr, Layout layout)
 
template<typename T >
void Delete (T *ptr)
 
StatusWithSize GetCapacity () const
 
bool IsEqual (const Deallocator &other) const
 

Static Public Attributes

static constexpr Capabilities kCapabilities
 
static constexpr size_t kMinSize = sizeof(void*)
 
static constexpr size_t kMinAlignment = alignof(void*)
 

Additional Inherited Members

- Public Types inherited from pw::Deallocator
using Capabilities = allocator::Capabilities
 
using Capability = allocator::Capability
 
using Layout = allocator::Layout
 
- Protected Member Functions inherited from pw::Deallocator
constexpr Deallocator ()=default
 TODO(b/326509341): Remove when downstream consumers migrate.
 
constexpr Deallocator (const Capabilities &capabilities)
 
template<typename T >
UniquePtr< T > WrapUnique (T *ptr)
 

Detailed Description

Implementation of Pool that uses a list of free chunks.

The first sizeof(void*) bytes of each free chunk is used to store a pointer to the next free chunk, or null for the last free chunk.

Constructor & Destructor Documentation

◆ ChunkPool()

pw::allocator::ChunkPool::ChunkPool ( ByteSpan  region,
const Layout layout 
)

Construct a Pool that allocates from a region of memory.

Parameters
regionThe memory to allocate from. Must be large enough to allocate at least one chunk with the given layout.
layoutThe size and alignment of the memory to be returned from this pool.

Member Data Documentation

◆ kCapabilities

constexpr Capabilities pw::allocator::ChunkPool::kCapabilities
staticconstexpr
Initial value:
=
kImplementsGetRequestedLayout | kImplementsGetUsableLayout |
kImplementsGetAllocatedLayout | kImplementsGetCapacity |
kImplementsRecognizes

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