proxygen
folly::FcSimpleExample< Mutex, Atom > Class Template Reference

#include <FlatCombiningExamples.h>

Inheritance diagram for folly::FcSimpleExample< Mutex, Atom >:
folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >

Public Member Functions

 FcSimpleExample (size_t size, bool dedicated=true, uint32_t numRecs=0, uint32_t maxOps=0)
 
uint64_t getVal ()
 
void addNoFC (uint64_t val)
 
void add (uint64_t val, Rec *rec=nullptr)
 
uint64_t fetchAddNoFC (uint64_t val)
 
uint64_t fetchAdd (uint64_t val, Rec *rec=nullptr)
 
- Public Member Functions inherited from folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >
 FlatCombining (const bool dedicated=true, const uint32_t numRecs=0, const uint32_t maxOps=0)
 
 ~FlatCombining ()
 
void drainAll ()
 
void acquireExclusive ()
 
bool tryExclusive ()
 
void releaseExclusive ()
 
void holdLock (LockHolder &l)
 
void holdLock (LockHolder &l, std::defer_lock_t)
 
void requestNoFC (OpFunc &opFn)
 
void requestFC (OpFunc &&opFn, Rec *rec=nullptr, bool syncop=true)
 
void requestFC (OpFunc &&opFn, const FillFunc &fillFn, Rec *rec=nullptr, bool syncop=true)
 
void requestFC (OpFunc &&opFn, const FillFunc &fillFn, const ResFn &resFn, Rec *rec=nullptr)
 
Rec * allocRec ()
 
void freeRec (Rec *rec)
 
uint64_t getNumUncombined () const
 
uint64_t getNumCombined () const
 
uint64_t getNumPasses () const
 
uint64_t getNumSessions () const
 

Private Types

using FC = FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >
 
using Rec = typename FC::Rec
 

Private Attributes

Data data_
 

Additional Inherited Members

- Public Types inherited from folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >
using Pool = folly::IndexedMemPool< Rec, 32, 4, Atom, IndexedMemPoolTraitsLazyRecycle< Rec >>
 
- Protected Member Functions inherited from folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >
void requestOp (OpFunc &&opFn, const FillFunc &fillFn, const ResFn &resFn, Rec *rec, bool syncop, const bool custom)
 
void pushRec (size_t idx)
 
size_t getRecsHead ()
 
size_t nextIndex (size_t idx)
 
void clearPending ()
 
void setPending ()
 
bool isPending () const
 
void awaitPending ()
 
uint64_t combiningSession ()
 
void tryCombining ()
 
void dedicatedCombining ()
 
void awaitDone (Rec &rec)
 
void awaitDoneTryLock (Rec &rec)
 
void shutdown ()
 
void combinedOp (bool &)
 The following member functions may be overridden for customization. More...
 
void processReq (Rec &rec)
 
uint64_t combiningPass ()
 
- Protected Attributes inherited from folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >
const size_t NULL_INDEX
 
const uint32_t kDefaultMaxOps
 
const uint64_t kDefaultNumRecs
 
const uint64_t kIdleThreshold
 
Mutex m_
 
folly::SaturatingSemaphore< true, Atompending_
 
Atom< bool > shutdown_
 
uint32_t numRecs_
 
uint32_t maxOps_
 
Atom< size_t > recs_
 
bool dedicated_
 
std::thread combiner_
 
Pool recsPool_
 
uint64_t uncombined_
 
uint64_t combined_
 
uint64_t passes_
 
uint64_t sessions_
 

Detailed Description

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
class folly::FcSimpleExample< Mutex, Atom >

Definition at line 75 of file FlatCombiningExamples.h.

Member Typedef Documentation

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
using folly::FcSimpleExample< Mutex, Atom >::FC = FlatCombining<FcSimpleExample<Mutex, Atom>, Mutex, Atom>
private

Definition at line 77 of file FlatCombiningExamples.h.

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
using folly::FcSimpleExample< Mutex, Atom >::Rec = typename FC::Rec
private

Definition at line 78 of file FlatCombiningExamples.h.

Constructor & Destructor Documentation

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
folly::FcSimpleExample< Mutex, Atom >::FcSimpleExample ( size_t  size,
bool  dedicated = true,
uint32_t  numRecs = 0,
uint32_t  maxOps = 0 
)
inlineexplicit

Definition at line 81 of file FlatCombiningExamples.h.

86  : FC(dedicated, numRecs, maxOps), data_(size) {}
static bool dedicated
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom > FC

Member Function Documentation

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
void folly::FcSimpleExample< Mutex, Atom >::add ( uint64_t  val,
Rec rec = nullptr 
)
inline

Definition at line 98 of file FlatCombiningExamples.h.

References data_, and val.

98  {
99  auto opFn = [&, val] { // asynchronous -- capture val by value
100  data_.add(val);
101  };
102  this->requestFC(opFn, rec, false);
103  }
double val
Definition: String.cpp:273
void add(uint64_t val)
void requestFC(OpFunc &&opFn, Rec *rec=nullptr, bool syncop=true)
template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
void folly::FcSimpleExample< Mutex, Atom >::addNoFC ( uint64_t  val)
inline

Definition at line 94 of file FlatCombiningExamples.h.

References data_.

94  {
95  this->requestNoFC([&] { data_.add(val); });
96  }
double val
Definition: String.cpp:273
void add(uint64_t val)
template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcSimpleExample< Mutex, Atom >::fetchAdd ( uint64_t  val,
Rec rec = nullptr 
)
inline

Definition at line 114 of file FlatCombiningExamples.h.

References data_, and uint64_t.

114  {
115  uint64_t res;
116  auto opFn = [&] { res = data_.fetchAdd(val); };
117  this->requestFC(opFn, rec);
118  return res;
119  }
double val
Definition: String.cpp:273
void requestFC(OpFunc &&opFn, Rec *rec=nullptr, bool syncop=true)
uint64_t fetchAdd(uint64_t val)
template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcSimpleExample< Mutex, Atom >::fetchAddNoFC ( uint64_t  val)
inline

Definition at line 107 of file FlatCombiningExamples.h.

References data_, and uint64_t.

107  {
108  uint64_t res;
109  auto opFn = [&] { res = data_.fetchAdd(val); };
110  this->requestNoFC(opFn);
111  return res;
112  }
double val
Definition: String.cpp:273
uint64_t fetchAdd(uint64_t val)
template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcSimpleExample< Mutex, Atom >::getVal ( )
inline

Definition at line 88 of file FlatCombiningExamples.h.

References data_.

88  {
89  return data_.getVal();
90  }

Member Data Documentation

template<typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
Data folly::FcSimpleExample< Mutex, Atom >::data_
private

Definition at line 122 of file FlatCombiningExamples.h.


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