44 static const size_t pageSize = sysconf (_SC_PAGESIZE);
47 size_t tot_size_rounded = (tot_size + (pageSize-1)) & ~(pageSize-1);
50 assert (n_rounded >= n);
52 (std::aligned_alloc (pageSize, tot_size_rounded));
53 if (!p)
throw std::bad_alloc();
56 p->m_elt_size = elt_size;
57 p->m_size = n_rounded;
59 for (
size_t i = 0; i < n_rounded; i++)
60 ctor (p->index (i, elt_size));
74 size_t elt_size = p->eltSize();
76 for (
size_t i = 0; i < n; i++) {
77 dtor (p->index (i, elt_size));
115 link = &(*link)->link();
138 size_t elt_size = p->eltSize();
143 for (
size_t i = 0; i < n; i++) {
144 func (p->index (i, elt_size));
191 PROT_READ + PROT_WRITE);
207 for (; p; p = p->link()) {
222 for (; p; p = p->link()) {
A large memory block that gets carved into smaller uniform elements. See Arena.h for an overview of t...
Exceptions that can be thrown from AthAllocators.
A large memory block that gets carved into smaller uniform elements.
static void protectList(ArenaBlock *p)
Write-protect all blocks in a list.
static void destroyList(ArenaBlock *p, func_t *dtor)
Destroy all blocks in a list.
static std::atomic< size_t > s_nactive
Global count of the number of blocks in use.
void func_t(pointer)
Function that operates on an element.
static void destroy(ArenaBlock *p, func_t *dtor)
Destroy a block.
static ArenaBlock * newBlock(size_t n, size_t elt_size, func_t *ctor)
Create a new block.
ArenaBlock *& link()
Return the link pointer of the block.
static void appendList(ArenaBlock **headp, ArenaBlock *tail)
Concatenate two lists of blocks.
size_t m_elt_size
Size, in bytes, of each element in this block.
static void unprotectList(ArenaBlock *p)
Write-enable all blocks in a list.
ArenaBlock(size_t n, size_t elt_size)
Prohibit calling these.
size_t m_size
Number of elements in this block.
void unprotect()
Write-enable this block.
static void applyList(ArenaBlock *p, func_t *func, size_t n)
Call a function on elements in a list of blocks.
static size_t overhead()
Return the per-block memory overhead, in bytes.
void protect()
Write-protect this block.
Exception — Attempt to change memory protection failed.
std::string tail(std::string s, const std::string &pattern)
tail of a string
static const int ArenaBlockBodyOffset
The offset from the start of the block to the first element.