Template Class PoolResource

Class Documentation

template<std::size_t M = 256>
class PoolResource

pools of the size classes of 8 bytes up to M, for one thread at a time

Public Functions

PoolResource(void)

an empty resource

PoolResource(const PoolResource&) = delete
PoolResource &operator=(const PoolResource&) = delete
~PoolResource() = default

frees the blocks; the objects still alive are not destroyed

template<std::size_t b, std::size_t a = alignof(std::max_align_t)>
void *allocate(void)

b bytes aligned to a, b and a known at compile time

template<std::size_t b, std::size_t a = alignof(std::max_align_t)>
void deallocate(void *p)
Pre:

p was given by allocate< b , a >()

void *allocate(std::size_t b, std::size_t a = alignof(std::max_align_t))

b bytes aligned to a

void deallocate(void *p, std::size_t b, std::size_t a = alignof(std::max_align_t))
Pre:

p was given by allocate( b , a )

std::size_t size(void) const

the number of objects alive in the classes

std::size_t bytes(void) const

the memory of the blocks of the classes, in bytes

Public Static Functions

static inline constexpr bool pooled(std::size_t b, std::size_t a)

true if a request of b bytes aligned to a takes a class

Public Static Attributes

static constexpr std::size_t GRAIN = 8

the step of a class

static constexpr std::size_t ALIGN = 16

the largest alignment

static constexpr std::size_t MAX = M

the largest class

static constexpr std::size_t CLASSES = M / GRAIN

the classes