Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
pw::allocator::AsyncPool Class Reference
Inheritance diagram for pw::allocator::AsyncPool:
pw::allocator::Pool pw::Deallocator

Public Member Functions

constexpr AsyncPool (Pool &pool)
 
async2::Poll< void * > PendAllocate (async2::Context &context)
 
- Public Member Functions inherited from pw::allocator::Pool
constexpr Pool (const Capabilities &capabilities, const Layout &layout)
 
constexpr const Layoutlayout () const
 
void * Allocate ()
 
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0, typename... Args>
T * New (Args &&... args)
 
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_bounded_array_v< T >, int > = 0>
ElementType * New ()
 
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0>
ElementType * New ()
 
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0, typename... Args>
UniquePtr< T > MakeUnique (Args &&... args)
 
template<typename T , int &... kExplicitGuard, std::enable_if_t< is_bounded_array_v< T >, int > = 0>
UniquePtr< T > MakeUnique ()
 
template<typename T , int &... kExplicitGuard, std::enable_if_t< is_unbounded_array_v< T >, int > = 0>
UniquePtr< T > MakeUnique ()
 
- Public Member Functions inherited from pw::Deallocator
constexpr const Capabilitiescapabilities () const
 
bool HasCapability (Capability capability) const
 Returns whether a given capability is enabled for this object.
 
void Deallocate (void *ptr)
 
void Deallocate (void *ptr, Layout layout)
 
template<typename ElementType >
void DeleteArray (ElementType *ptr, size_t count)
 
StatusWithSize GetCapacity () const
 
bool IsEqual (const Deallocator &other) const
 
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0>
void Delete (T *ptr)
 
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_bounded_array_v< T >, int > = 0>
void Delete (ElementType *ptr)
 
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0>
void Delete (ElementType *ptr, size_t count)
 

Private Member Functions

void * DoAllocate () override
 
void DoDeallocate (void *ptr) override
 

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 , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0>
UniquePtr< T > WrapUnique (ElementType *ptr, size_t size)
 
- Static Protected Attributes inherited from pw::Deallocator
template<typename T >
static constexpr bool is_bounded_array_v
 
template<typename T >
static constexpr bool is_unbounded_array_v
 

Detailed Description

A wrapper around a Pool that allows for asynchronous allocation.

This class is not thread safe. It should only be used from the dispatcher thread, or wrapped to provided synchronized access.

Member Function Documentation

◆ DoAllocate()

void * pw::allocator::AsyncPool::DoAllocate ( )
overrideprivatevirtual

Returns a chunk of memory with this object's fixed layout.

Like pw::allocator::Allocate, returns null if memory is exhausted.

Return values
Theallocated memory.

Implements pw::allocator::Pool.

◆ DoDeallocate()

void pw::allocator::AsyncPool::DoDeallocate ( void *  ptr)
overrideprivate

Releases a previously-allocated block of memory.

The given pointer must have been previously provided by this memory resource; otherwise the behavior is undefined.

Parameters
[in]ptrPointer to previously-allocated memory.

◆ PendAllocate()

async2::Poll< void * > pw::allocator::AsyncPool::PendAllocate ( async2::Context context)

Asynchronously allocates a chunk of memory with the fixed layout from the pool.


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