proxygen
folly::fbvector< T, Allocator >::Impl Struct Reference
Inheritance diagram for folly::fbvector< T, Allocator >::Impl:

Public Types

typedef A::pointer pointer
 
typedef A::size_type size_type
 

Public Member Functions

 Impl ()
 
 Impl (const Allocator &alloc)
 
 Impl (Allocator &&alloc)
 
 Impl (size_type n, const Allocator &alloc=Allocator())
 
 Impl (Impl &&other) noexcept
 
 ~Impl ()
 
TD_allocate (size_type n)
 
void D_deallocate (T *p, size_type n) noexcept
 
void swapData (Impl &other)
 
void destroy () noexcept
 
void init (size_type n)
 
void set (pointer newB, size_type newSize, size_type newCap)
 
void reset (size_type newCap)
 
void reset ()
 

Public Attributes

pointer b_
 
pointer e_
 
pointer z_
 

Detailed Description

template<class T, class Allocator>
struct folly::fbvector< T, Allocator >::Impl

Definition at line 84 of file FBVector.h.

Member Typedef Documentation

template<class T, class Allocator>
typedef A::pointer folly::fbvector< T, Allocator >::Impl::pointer

Definition at line 86 of file FBVector.h.

template<class T, class Allocator>
typedef A::size_type folly::fbvector< T, Allocator >::Impl::size_type

Definition at line 87 of file FBVector.h.

Constructor & Destructor Documentation

template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::Impl ( )
inline

Definition at line 93 of file FBVector.h.

93 : Allocator(), b_(nullptr), e_(nullptr), z_(nullptr) {}
template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::Impl ( const Allocator &  alloc)
inline

Definition at line 94 of file FBVector.h.

95  : Allocator(alloc), b_(nullptr), e_(nullptr), z_(nullptr) {}
template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::Impl ( Allocator &&  alloc)
inline

Definition at line 96 of file FBVector.h.

97  : Allocator(std::move(alloc)), b_(nullptr), e_(nullptr), z_(nullptr) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::Impl ( size_type  n,
const Allocator &  alloc = Allocator() 
)
inline

Definition at line 99 of file FBVector.h.

References folly::fbvector< T, Allocator >::Impl::init().

100  : Allocator(alloc) {
101  init(n);
102  }
void init(size_type n)
Definition: FBVector.h:158
template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::Impl ( Impl &&  other)
inlinenoexcept

Definition at line 104 of file FBVector.h.

105  : Allocator(std::move(other)),
106  b_(other.b_),
107  e_(other.e_),
108  z_(other.z_) {
109  other.b_ = other.e_ = other.z_ = nullptr;
110  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T, class Allocator>
folly::fbvector< T, Allocator >::Impl::~Impl ( )
inline

Definition at line 113 of file FBVector.h.

References folly::fbvector< T, Allocator >::Impl::destroy().

113  {
114  destroy();
115  }
void destroy() noexcept
Definition: FBVector.h:143

Member Function Documentation

template<class T, class Allocator>
T* folly::fbvector< T, Allocator >::Impl::D_allocate ( size_type  n)
inline

Definition at line 119 of file FBVector.h.

References folly::checkedMalloc(), folly::T, and value.

Referenced by folly::fbvector< T, Allocator >::Impl::init().

119  {
121  return static_cast<T*>(checkedMalloc(n * sizeof(T)));
122  } else {
123  return std::allocator_traits<Allocator>::allocate(*this, n);
124  }
125  }
void * checkedMalloc(size_t size)
Definition: Malloc.h:227
folly::std T
static const char *const value
Definition: Conv.cpp:50
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::D_deallocate ( T p,
size_type  n 
)
inlinenoexcept

Definition at line 127 of file FBVector.h.

References bm::free(), and value.

Referenced by folly::fbvector< T, Allocator >::Impl::destroy().

127  {
129  free(p);
130  } else {
131  std::allocator_traits<Allocator>::deallocate(*this, p, n);
132  }
133  }
static const char *const value
Definition: Conv.cpp:50
void free()
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::destroy ( )
inlinenoexcept

Definition at line 143 of file FBVector.h.

References folly::fbvector< T, Allocator >::Impl::D_deallocate(), folly::fbvector< T, Allocator >::S_destroy_range(), folly::fbvector< T, Allocator >::S_destroy_range_a(), and value.

Referenced by folly::fbvector< T, Allocator >::Impl::reset(), and folly::fbvector< T, Allocator >::Impl::~Impl().

143  {
144  if (b_) {
145  // THIS DISPATCH CODE IS DUPLICATED IN fbvector::D_destroy_range_a.
146  // It has been inlined here for speed. It calls the static fbvector
147  // methods to perform the actual destruction.
150  } else {
151  S_destroy_range_a(*this, b_, e_);
152  }
153 
155  }
156  }
static void S_destroy_range_a(Allocator &a, T *first, T *last) noexcept
Definition: FBVector.h:372
static void S_destroy_range(T *first, T *last) noexcept
Definition: FBVector.h:379
A::size_type size_type
Definition: FBVector.h:87
void D_deallocate(T *p, size_type n) noexcept
Definition: FBVector.h:127
static const char *const value
Definition: Conv.cpp:50
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::init ( size_type  n)
inline

Definition at line 158 of file FBVector.h.

References folly::fbvector< T, Allocator >::Impl::b_, folly::fbvector< T, Allocator >::Impl::D_allocate(), folly::goodMallocSize(), folly::T, and UNLIKELY.

Referenced by folly::fbvector< HTTPHeaderCode >::fbvector(), folly::fbvector< T, Allocator >::Impl::Impl(), and folly::fbvector< T, Allocator >::Impl::reset().

158  {
159  if (UNLIKELY(n == 0)) {
160  b_ = e_ = z_ = nullptr;
161  } else {
162  size_type sz = folly::goodMallocSize(n * sizeof(T)) / sizeof(T);
163  b_ = D_allocate(sz);
164  e_ = b_;
165  z_ = b_ + sz;
166  }
167  }
T * D_allocate(size_type n)
Definition: FBVector.h:119
A::size_type size_type
Definition: FBVector.h:87
folly::std T
#define UNLIKELY(x)
Definition: Likely.h:48
size_t goodMallocSize(size_t minSize) noexcept
Definition: Malloc.h:201
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::reset ( size_type  newCap)
inline
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::reset ( )
inline

Definition at line 184 of file FBVector.h.

References folly::fbvector< T, Allocator >::Impl::destroy(), and folly::fbvector< T, Allocator >::impl_.

184  { // same as reset(0)
185  destroy();
186  b_ = e_ = z_ = nullptr;
187  }
void destroy() noexcept
Definition: FBVector.h:143
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::set ( pointer  newB,
size_type  newSize,
size_type  newCap 
)
inline

Definition at line 169 of file FBVector.h.

Referenced by folly::fbvector< HTTPHeaderCode >::do_real_insert().

169  {
170  z_ = newB + newCap;
171  e_ = newB + newSize;
172  b_ = newB;
173  }
template<class T, class Allocator>
void folly::fbvector< T, Allocator >::Impl::swapData ( Impl other)
inline

Member Data Documentation


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