proxygen
folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial > Struct Template Reference

#include <IndexedMemPool.h>

Static Public Member Functions

static constexpr bool eagerRecycle ()
 
static void initialize (T *ptr)
 
static void cleanup (T *ptr)
 
template<typename... Args>
static void onAllocate (T *ptr, Args &&...args)
 
static void onRecycle (T *ptr)
 Called when the element is recycled. More...
 

Detailed Description

template<typename T, bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
struct folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >

Definition at line 47 of file IndexedMemPool.h.

Member Function Documentation

template<typename T , bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
static void folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >::cleanup ( T ptr)
inlinestatic

Called when the element pointed to by ptr is freed at the pool destruction time.

Definition at line 63 of file IndexedMemPool.h.

References testing::Args().

63  {
64  if (!eagerRecycle()) {
65  ptr->~T();
66  }
67  }
void * ptr
static constexpr bool eagerRecycle()
template<typename T , bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
static constexpr bool folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >::eagerRecycle ( )
inlinestatic

Definition at line 48 of file IndexedMemPool.h.

References value.

48  {
49  return std::is_trivial<T>::value ? EagerRecycleWhenTrivial
50  : EagerRecycleWhenNotTrivial;
51  }
static const char *const value
Definition: Conv.cpp:50
template<typename T , bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
static void folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >::initialize ( T ptr)
inlinestatic

Called when the element pointed to by ptr is allocated for the first time.

Definition at line 55 of file IndexedMemPool.h.

References ptr, and T.

55  {
56  if (!eagerRecycle()) {
57  new (ptr) T();
58  }
59  }
void * ptr
static constexpr bool eagerRecycle()
folly::std T
template<typename T , bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
template<typename... Args>
static void folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >::onAllocate ( T ptr,
Args &&...  args 
)
inlinestatic

Called when the element is allocated with the arguments forwarded from IndexedMemPool::allocElem.

Definition at line 72 of file IndexedMemPool.h.

References testing::Args(), ptr, and T.

72  {
73  static_assert(
74  sizeof...(Args) == 0 || eagerRecycle(),
75  "emplace-style allocation requires eager recycle, "
76  "which is defaulted only for non-trivial types");
77  if (eagerRecycle()) {
78  new (ptr) T(std::forward<Args>(args)...);
79  }
80  }
void * ptr
static constexpr bool eagerRecycle()
folly::std T
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
template<typename T , bool EagerRecycleWhenTrivial = false, bool EagerRecycleWhenNotTrivial = true>
static void folly::IndexedMemPoolTraits< T, EagerRecycleWhenTrivial, EagerRecycleWhenNotTrivial >::onRecycle ( T ptr)
inlinestatic

Called when the element is recycled.

Definition at line 83 of file IndexedMemPool.h.

83  {
84  if (eagerRecycle()) {
85  ptr->~T();
86  }
87  }
void * ptr
static constexpr bool eagerRecycle()

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