proxygen
folly::CachelinePadded< T > Class Template Reference

#include <CachelinePadded.h>

Public Member Functions

template<typename... Args>
 CachelinePadded (Args &&...args)
 
Tget ()
 
const Tget () const
 
Toperator-> ()
 
const Toperator-> () const
 
Toperator* ()
 
const Toperator* () const
 

Static Private Member Functions

static constexpr size_t paddingSize () noexcept
 

Private Attributes

char paddingPre_ [paddingSize()]
 
T inner_
 
char paddingPost_ [paddingSize()]
 

Detailed Description

template<typename T>
class folly::CachelinePadded< T >

Holds a type T, in addition to enough padding to ensure that it isn't subject to false sharing within the range used by folly.

If sizeof(T) <= alignof(T) then the inner T will be entirely within one false sharing range (AKA cache line).

CachelinePadded may add padding both before and after the value. Consider whether alignas(folly::hardware_destructive_interference_size) suffices.

Definition at line 37 of file CachelinePadded.h.

Constructor & Destructor Documentation

template<typename T>
template<typename... Args>
folly::CachelinePadded< T >::CachelinePadded ( Args &&...  args)
inlineexplicit

Definition at line 44 of file CachelinePadded.h.

45  : inner_(std::forward<Args>(args)...) {}

Member Function Documentation

template<typename T>
T* folly::CachelinePadded< T >::get ( )
inline

Definition at line 47 of file CachelinePadded.h.

Referenced by TEST(), and TYPED_TEST().

47  {
48  return &inner_;
49  }
template<typename T>
const T* folly::CachelinePadded< T >::get ( ) const
inline

Definition at line 51 of file CachelinePadded.h.

51  {
52  return &inner_;
53  }
template<typename T>
T& folly::CachelinePadded< T >::operator* ( )
inline

Definition at line 63 of file CachelinePadded.h.

63  {
64  return *get();
65  }
template<typename T>
const T& folly::CachelinePadded< T >::operator* ( ) const
inline

Definition at line 67 of file CachelinePadded.h.

67  {
68  return *get();
69  }
template<typename T>
T* folly::CachelinePadded< T >::operator-> ( )
inline

Definition at line 55 of file CachelinePadded.h.

55  {
56  return get();
57  }
template<typename T>
const T* folly::CachelinePadded< T >::operator-> ( ) const
inline

Definition at line 59 of file CachelinePadded.h.

59  {
60  return get();
61  }
template<typename T>
static constexpr size_t folly::CachelinePadded< T >::paddingSize ( )
inlinestaticprivatenoexcept

Definition at line 72 of file CachelinePadded.h.

72  {
75  }
folly::std T
constexpr std::size_t hardware_destructive_interference_size
Definition: Align.h:107

Member Data Documentation

template<typename T>
T folly::CachelinePadded< T >::inner_
private
template<typename T>
char folly::CachelinePadded< T >::paddingPost_[paddingSize()]
private

Definition at line 78 of file CachelinePadded.h.

template<typename T>
char folly::CachelinePadded< T >::paddingPre_[paddingSize()]
private

Definition at line 76 of file CachelinePadded.h.


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