proxygen
folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >:
folly::gen::GenImpl< VectorType &, Generator< Value, Source, StorageType, VectorType > > folly::gen::FBounded< Self >

Public Member Functions

 Generator (Source source, size_t batchSize)
 
template<class Handler >
bool apply (Handler &&handler) const
 
- Public Member Functions inherited from folly::gen::GenImpl< VectorType &, Generator< Value, Source, StorageType, VectorType > >
bool apply (Handler &&handler) const
 
void foreach (Body &&body) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Static Public Attributes

static constexpr bool infinite = Source::infinite
 
- Static Public Attributes inherited from folly::gen::GenImpl< VectorType &, Generator< Value, Source, StorageType, VectorType > >
static constexpr bool infinite
 

Private Attributes

Source source_
 
size_t batchSize_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< VectorType &, Generator< Value, Source, StorageType, VectorType > >
typedef VectorType & ValueType
 
typedef std::decay< VectorType & >::type StorageType
 
- Protected Member Functions inherited from folly::gen::GenImpl< VectorType &, Generator< Value, Source, StorageType, VectorType > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Value, class Source, class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
class folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >

Definition at line 1458 of file Base-inl.h.

Constructor & Destructor Documentation

template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >::Generator ( Source  source,
size_t  batchSize 
)
inlineexplicit

Definition at line 1465 of file Base-inl.h.

1466  : source_(std::move(source)), batchSize_(batchSize) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
template<class Handler >
bool folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >::apply ( Handler &&  handler) const
inline

Definition at line 1469 of file Base-inl.h.

References handler(), value, and testing::Value().

1469  {
1470  VectorType batch_;
1471  batch_.reserve(batchSize_);
1472  bool shouldContinue = source_.apply([&](Value value) -> bool {
1473  batch_.push_back(std::forward<Value>(value));
1474  if (batch_.size() == batchSize_) {
1475  bool needMore = handler(batch_);
1476  batch_.clear();
1477  return needMore;
1478  }
1479  // Always need more if the handler is not called.
1480  return true;
1481  });
1482  // Flush everything, if and only if `handler` hasn't returned false.
1483  if (shouldContinue && !batch_.empty()) {
1484  shouldContinue = handler(batch_);
1485  batch_.clear();
1486  }
1487  return shouldContinue;
1488  }
void handler(int, siginfo_t *, void *)
bool Value(const T &value, M matcher)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)

Member Data Documentation

template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
size_t folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >::batchSize_
private

Definition at line 1462 of file Base-inl.h.

template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
constexpr bool folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >::infinite = Source::infinite
static

Definition at line 1491 of file Base-inl.h.

template<class Value , class Source , class StorageType = typename std::decay<Value>::type, class VectorType = std::vector<StorageType>>
Source folly::gen::detail::Batch::Generator< Value, Source, StorageType, VectorType >::source_
private

Definition at line 1461 of file Base-inl.h.


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