proxygen
folly::FcCustomExample< Req, Mutex, Atom > Class Template Reference

#include <FlatCombiningExamples.h>

Inheritance diagram for folly::FcCustomExample< Req, Mutex, Atom >:
folly::FlatCombining< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >

Public Member Functions

 FcCustomExample (int 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)
 
void combinedOp (Req &req)
 
- Public Member Functions inherited from folly::FlatCombining< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >
 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< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >
 
using Rec = typename FC::Rec
 

Private Attributes

Data data_
 

Additional Inherited Members

- Public Types inherited from folly::FlatCombining< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >
using Pool = folly::IndexedMemPool< Rec, 32, 4, Atom, IndexedMemPoolTraitsLazyRecycle< Rec >>
 
- Protected Member Functions inherited from folly::FlatCombining< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >
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 (Req &)
 The following member functions may be overridden for customization. More...
 
void processReq (Rec &rec)
 
uint64_t combiningPass ()
 
- Protected Attributes inherited from folly::FlatCombining< FcCustomExample< Req, Mutex, Atom >, Mutex, Atom, Req >
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 Req, typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
class folly::FcCustomExample< Req, Mutex, Atom >

Definition at line 165 of file FlatCombiningExamples.h.

Member Typedef Documentation

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

Definition at line 170 of file FlatCombiningExamples.h.

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

Definition at line 171 of file FlatCombiningExamples.h.

Constructor & Destructor Documentation

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

Definition at line 174 of file FlatCombiningExamples.h.

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

Member Function Documentation

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

Definition at line 191 of file FlatCombiningExamples.h.

References folly::Req::ADD, data_, and val.

191  {
192  auto opFn = [&, val] { data_.add(val); };
193  auto fillFn = [&](Req& req) {
194  req.setType(Req::Type::ADD);
195  req.setVal(val);
196  };
197  this->requestFC(opFn, fillFn, rec, false); // asynchronous
198  }
double val
Definition: String.cpp:273
void add(uint64_t val)
void requestFC(OpFunc &&opFn, Rec *rec=nullptr, bool syncop=true)
template<typename Req , typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
void folly::FcCustomExample< Req, Mutex, Atom >::addNoFC ( uint64_t  val)
inline

Definition at line 187 of file FlatCombiningExamples.h.

References data_.

187  {
188  this->requestNoFC([&] { data_.add(val); });
189  }
double val
Definition: String.cpp:273
void add(uint64_t val)
template<typename Req , typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
void folly::FcCustomExample< Req, Mutex, Atom >::combinedOp ( Req req)
inline

Definition at line 222 of file FlatCombiningExamples.h.

References folly::Req::ADD, folly::assume_unreachable(), data_, folly::Req::FETCHADD, folly::Req::getType(), folly::Req::getVal(), and folly::Req::setRes().

222  {
223  switch (req.getType()) {
224  case Req::Type::ADD:
225  data_.add(req.getVal());
226  return;
227  case Req::Type::FETCHADD:
228  req.setRes(data_.fetchAdd(req.getVal()));
229  return;
230  }
232  }
void add(uint64_t val)
FOLLY_ALWAYS_INLINE void assume_unreachable()
Definition: Assume.h:59
uint64_t fetchAdd(uint64_t val)
template<typename Req , typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcCustomExample< Req, Mutex, Atom >::fetchAdd ( uint64_t  val,
Rec rec = nullptr 
)
inline

Definition at line 209 of file FlatCombiningExamples.h.

References data_, folly::Req::FETCHADD, and uint64_t.

209  {
210  uint64_t res;
211  auto opFn = [&] { res = data_.fetchAdd(val); };
212  auto fillFn = [&](Req& req) {
213  req.setType(Req::Type::FETCHADD);
214  req.setVal(val);
215  };
216  auto resFn = [&](Req& req) { res = req.getRes(); };
217  this->requestFC(opFn, fillFn, resFn, rec);
218  return res;
219  }
double val
Definition: String.cpp:273
void requestFC(OpFunc &&opFn, Rec *rec=nullptr, bool syncop=true)
uint64_t fetchAdd(uint64_t val)
template<typename Req , typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcCustomExample< Req, Mutex, Atom >::fetchAddNoFC ( uint64_t  val)
inline

Definition at line 202 of file FlatCombiningExamples.h.

References data_, and uint64_t.

202  {
203  uint64_t res;
204  auto opFn = [&] { res = data_.fetchAdd(val); };
205  this->requestNoFC(opFn);
206  return res;
207  }
double val
Definition: String.cpp:273
uint64_t fetchAdd(uint64_t val)
template<typename Req , typename Mutex = std::mutex, template< typename > class Atom = std::atomic>
uint64_t folly::FcCustomExample< Req, Mutex, Atom >::getVal ( )
inline

Definition at line 181 of file FlatCombiningExamples.h.

References data_.

181  {
182  return data_.getVal();
183  }

Member Data Documentation

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

Definition at line 235 of file FlatCombiningExamples.h.


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