17 #ifndef FOLLY_ARENA_H_ 18 #error This file may only be included from Arena.h 25 template <
class Alloc>
26 std::pair<typename Arena<Alloc>::Block*,
size_t>
28 size_t allocSize =
sizeof(
Block) + size;
33 void* mem = std::allocator_traits<Alloc>::allocate(alloc, allocSize);
34 return std::make_pair(
new (mem)
Block(), allocSize -
sizeof(
Block));
37 template <
class Alloc>
40 std::allocator_traits<Alloc>::deallocate(alloc,
this, 1);
43 template <
class Alloc>
45 std::pair<Block*, size_t> p;
60 start = p.first->start();
65 start = p.first->start();
68 end_ = start + p.second;
71 assert(p.second >= size);
76 template <
class Alloc>
79 other.blocks_.clear();
80 other.ptr_ = other.end_ =
nullptr;
82 other.totalAllocatedSize_ = 0;
85 template <
class Alloc>
87 auto disposer = [
this](
Block*
b) {
b->deallocate(this->
alloc()); };
89 blocks_.pop_front_and_dispose(disposer);
static constexpr size_t kNoSizeLimit
static std::pair< Block *, size_t > allocate(Alloc &alloc, size_t size, bool allowSlack)
—— Concurrent Priority Queue Implementation ——
static size_t goodSize(const Alloc &, size_t size)
void deallocate(Alloc &alloc)
void merge(Arena &&other)
constexpr auto size(C const &c) -> decltype(c.size())
size_t totalAllocatedSize_
void * allocateSlow(size_t size)
size_t minBlockSize() const
FOLLY_NOINLINE FOLLY_COLD void throw_exception(Ex &&ex)