Template Class ConcurrentPoolResource

Nested Relationships

Nested Types

Class Documentation

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

pools of the size classes of 8 bytes up to M, a heap per thread, the objects freed by any thread

Public Functions

ConcurrentPoolResource(void)

an empty resource

ConcurrentPoolResource(const ConcurrentPoolResource&) = delete
ConcurrentPoolResource &operator=(const ConcurrentPoolResource&) = delete
~ConcurrentPoolResource()

frees the segments and the heaps; 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 >(), by any thread

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 ), by any thread

void collect(void)

the batches of the calling thread go back to their heaps, and the slots that other threads freed into its heap go on its free lists

std::size_t heaps(void) const

the number of heaps, one per thread that used the resource

std::size_t bytes(void) const

the memory of the segments, 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

static ConcurrentPoolResource &global(void)

the resource of the whole program, never destroyed

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

static constexpr std::size_t SEGMENT = detail::PageHeap<CLASSES>::SEGMENT