proxygen
folly::detail::CompressionCounter Class Reference

Wrapper around the makeCompressionCounterHandler() extension point. More...

#include <Counters.h>

Public Member Functions

 CompressionCounter ()
 
 CompressionCounter (folly::io::CodecType codecType, folly::StringPiece codecName, folly::Optional< int > level, CompressionCounterKey key, CompressionCounterType counterType)
 
void operator+= (double sum)
 
void operator++ ()
 
void operator++ (int)
 
bool hasImplementation ()
 

Private Member Functions

void performLazyInit ()
 

Private Attributes

bool initialized_ {false}
 
folly::Function< folly::Function< void(double)>)> initialize_
 
folly::Function< void(double)> increment_
 

Detailed Description

Wrapper around the makeCompressionCounterHandler() extension point.

Definition at line 70 of file Counters.h.

Constructor & Destructor Documentation

folly::detail::CompressionCounter::CompressionCounter ( )
inline

Definition at line 72 of file Counters.h.

72 {}
folly::detail::CompressionCounter::CompressionCounter ( folly::io::CodecType  codecType,
folly::StringPiece  codecName,
folly::Optional< int >  level,
CompressionCounterKey  key,
CompressionCounterType  counterType 
)
inline

Definition at line 73 of file Counters.h.

References folly::makeCompressionCounterHandler().

78  {
79  initialize_ = [=]() {
81  codecType, codecName, level, key, counterType);
82  };
83  DCHECK(!initialize_.hasAllocatedMemory());
84  }
FOLLY_ATTR_WEAK folly::Function< void(double)> makeCompressionCounterHandler(folly::io::CodecType, folly::StringPiece, folly::Optional< int >, CompressionCounterKey, CompressionCounterType)
Definition: Counters.cpp:21
folly::Function< folly::Function< void(double)>)> initialize_
Definition: Counters.h:116

Member Function Documentation

bool folly::detail::CompressionCounter::hasImplementation ( )
inline

Definition at line 101 of file Counters.h.

101  {
102  performLazyInit();
103  return static_cast<bool>(increment_);
104  }
folly::Function< void(double)> increment_
Definition: Counters.h:117
void folly::detail::CompressionCounter::operator++ ( )
inline

Definition at line 93 of file Counters.h.

93  {
94  *this += 1.0;
95  }
void folly::detail::CompressionCounter::operator++ ( int  )
inline

Definition at line 97 of file Counters.h.

97  {
98  *this += 1.0;
99  }
void folly::detail::CompressionCounter::operator+= ( double  sum)
inline

Definition at line 86 of file Counters.h.

86  {
88  if (increment_) {
89  increment_(sum);
90  }
91  }
std::atomic< int64_t > sum(0)
folly::Function< void(double)> increment_
Definition: Counters.h:117
void folly::detail::CompressionCounter::performLazyInit ( )
inlineprivate

Definition at line 107 of file Counters.h.

107  {
108  if (!initialized_) {
109  initialized_ = true;
111  initialize_ = {};
112  }
113  }
folly::Function< void(double)> increment_
Definition: Counters.h:117
folly::Function< folly::Function< void(double)>)> initialize_
Definition: Counters.h:116

Member Data Documentation

folly::Function<void(double)> folly::detail::CompressionCounter::increment_
private

Definition at line 117 of file Counters.h.

folly::Function<folly::Function<void(double)>)> folly::detail::CompressionCounter::initialize_
private

Definition at line 116 of file Counters.h.

bool folly::detail::CompressionCounter::initialized_ {false}
private

Definition at line 115 of file Counters.h.


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