Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Public Types | Public Member Functions | Private Attributes | Friends | List of all members
PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > Class Template Reference

Forwards all allocations/deallocations to the PoolResource. More...

#include <pool.h>

Collaboration diagram for PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >:
[legend]

Classes

struct  rebind
 The rebind struct here is mandatory because we use non type template arguments for PoolAllocator. More...
 

Public Types

using value_type = T
 
using ResourceType = PoolResource< MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >
 

Public Member Functions

 PoolAllocator (ResourceType *resource) noexcept
 Not explicit so we can easily construct it with the correct resource. More...
 
 PoolAllocator (const PoolAllocator &other) noexcept=default
 
PoolAllocatoroperator= (const PoolAllocator &other) noexcept=default
 
template<class U >
 PoolAllocator (const PoolAllocator< U, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &other) noexcept
 
Tallocate (size_t n)
 Forwards each call to the resource. More...
 
void deallocate (T *p, size_t n) noexcept
 Forwards each call to the resource. More...
 
ResourceTyperesource () const noexcept
 

Private Attributes

PoolResource< MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > * m_resource
 

Friends

template<typename U , std::size_t M, std::size_t A>
class PoolAllocator
 

Detailed Description

template<class T, std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
class PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >

Forwards all allocations/deallocations to the PoolResource.

Definition at line 276 of file pool.h.

Member Typedef Documentation

◆ ResourceType

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
using PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::ResourceType = PoolResource<MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES>

Definition at line 285 of file pool.h.

◆ value_type

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
using PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::value_type = T

Definition at line 284 of file pool.h.

Constructor & Destructor Documentation

◆ PoolAllocator() [1/3]

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::PoolAllocator ( ResourceType resource)
inlinenoexcept

Not explicit so we can easily construct it with the correct resource.

Definition at line 290 of file pool.h.

◆ PoolAllocator() [2/3]

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::PoolAllocator ( const PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &  other)
defaultnoexcept

◆ PoolAllocator() [3/3]

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
template<class U >
PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::PoolAllocator ( const PoolAllocator< U, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &  other)
inlinenoexcept

Definition at line 299 of file pool.h.

Member Function Documentation

◆ allocate()

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
T* PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::allocate ( size_t  n)
inline

Forwards each call to the resource.

Definition at line 316 of file pool.h.

◆ deallocate()

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
void PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::deallocate ( T p,
size_t  n 
)
inlinenoexcept

Forwards each call to the resource.

Definition at line 324 of file pool.h.

◆ operator=()

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
PoolAllocator& PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::operator= ( const PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &  other)
defaultnoexcept

◆ resource()

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
ResourceType* PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::resource ( ) const
inlinenoexcept

Definition at line 329 of file pool.h.

Friends And Related Function Documentation

◆ PoolAllocator

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
template<typename U , std::size_t M, std::size_t A>
friend class PoolAllocator
friend

Definition at line 281 of file pool.h.

Member Data Documentation

◆ m_resource

template<class T , std::size_t MAX_BLOCK_SIZE_BYTES, std::size_t ALIGN_BYTES = alignof(T)>
PoolResource<MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES>* PoolAllocator< T, MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES >::m_resource
private

Definition at line 278 of file pool.h.


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