proxygen
folly::Arena< Alloc >::Block Struct Reference

Public Member Functions

void deallocate (Alloc &alloc)
 
char * start ()
 

Static Public Member Functions

static std::pair< Block *, size_t > allocate (Alloc &alloc, size_t size, bool allowSlack)
 

Public Attributes

BlockLink link
 

Private Member Functions

 Block ()=default
 
 ~Block ()=default
 

Detailed Description

template<class Alloc>
struct folly::Arena< Alloc >::Block

Definition at line 132 of file Arena.h.

Constructor & Destructor Documentation

template<class Alloc>
folly::Arena< Alloc >::Block::Block ( )
privatedefault
template<class Alloc>
folly::Arena< Alloc >::Block::~Block ( )
privatedefault

Member Function Documentation

template<class Alloc>
std::pair< typename Arena< Alloc >::Block *, size_t > folly::Arena< Alloc >::Block::allocate ( Alloc alloc,
size_t  size,
bool  allowSlack 
)
static

Definition at line 27 of file Arena-inl.h.

References folly::Arena< Alloc >::Block::Block(), and folly::ArenaAllocatorTraits< Alloc >::goodSize().

Referenced by folly::Arena< Alloc >::allocateSlow().

27  {
28  size_t allocSize = sizeof(Block) + size;
29  if (allowSlack) {
30  allocSize = ArenaAllocatorTraits<Alloc>::goodSize(alloc, allocSize);
31  }
32 
33  void* mem = std::allocator_traits<Alloc>::allocate(alloc, allocSize);
34  return std::make_pair(new (mem) Block(), allocSize - sizeof(Block));
35 }
static size_t goodSize(const Alloc &, size_t size)
Definition: Arena.h:219
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
template<class Alloc>
void folly::Arena< Alloc >::Block::deallocate ( Alloc alloc)

Definition at line 38 of file Arena-inl.h.

References folly::Arena< Alloc >::Block::~Block().

38  {
39  this->~Block();
40  std::allocator_traits<Alloc>::deallocate(alloc, this, 1);
41 }
template<class Alloc>
char* folly::Arena< Alloc >::Block::start ( )
inline

Definition at line 143 of file Arena.h.

Referenced by folly::Arena< Alloc >::allocateSlow().

143  {
144  return reinterpret_cast<char*>(this + 1);
145  }

Member Data Documentation

template<class Alloc>
BlockLink folly::Arena< Alloc >::Block::link

Definition at line 133 of file Arena.h.


The documentation for this struct was generated from the following files: