 |
ATLAS Offline Software
|
Go to the documentation of this file.
44 static const size_t pageSize = sysconf (_SC_PAGESIZE);
45 size_t tot_size =
n*elt_size + ArenaBlockBodyOffset;
47 size_t tot_size_rounded = (tot_size + (pageSize-1)) & ~(pageSize-1);
49 size_t n_rounded = (tot_size_rounded - ArenaBlockBodyOffset) / elt_size;
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));
138 size_t elt_size =
p->eltSize();
143 for (
size_t i = 0;
i <
n;
i++) {
144 func (
p->index (
i, elt_size));
162 return ArenaBlockBodyOffset +
sizeof (size_t);
191 PROT_READ + PROT_WRITE);
207 for (;
p;
p =
p->link()) {
222 for (;
p;
p =
p->link()) {
Exception — Attempt to change memory protection failed.
void unprotect()
Write-enable this block.
static void destroy(ArenaBlock *p, func_t *dtor)
Destroy a block.
std::string tail(std::string s, const std::string &pattern)
tail of a string
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.
static ArenaBlock * newBlock(size_t n, size_t elt_size, func_t *ctor)
Create a new block.
static void appendList(ArenaBlock **headp, ArenaBlock *tail)
Concatenate two lists of blocks.
static void unprotectList(ArenaBlock *p)
Write-enable all blocks in a list.
ArenaBlock *& link()
Return the link pointer of the block.
size_t m_size
Number of elements in this block.
A large memory block that gets carved into smaller uniform elements.
static std::atomic< size_t > s_nactive
Global count of the number of blocks in use.
size_t m_elt_size
Size, in bytes, of each element in this block.
static void protectList(ArenaBlock *p)
Write-protect all blocks in a list.
void protect()
Write-protect this block.
static void destroyList(ArenaBlock *p, func_t *dtor)
Destroy all blocks in a list.
Exceptions that can be thrown from AthAllocators.
A large memory block that gets carved into smaller uniform elements. See Arena.h for an overview of t...