proxygen
folly::gen::detail::ChunkedRangeSource< Iterator > Class Template Reference

#include <Parallel-inl.h>

Inheritance diagram for folly::gen::detail::ChunkedRangeSource< Iterator >:
folly::gen::GenImpl< RangeSource< Iterator > &&, ChunkedRangeSource< Iterator > > folly::gen::FBounded< Self >

Public Member Functions

 ChunkedRangeSource ()=default
 
 ChunkedRangeSource (int chunkSize, Range< Iterator > range)
 
template<class Handler >
bool apply (Handler &&handler) const
 
- Public Member Functions inherited from folly::gen::GenImpl< RangeSource< Iterator > &&, ChunkedRangeSource< Iterator > >
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 ()
 

Private Attributes

int chunkSize_
 
Range< Iterator > range_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< RangeSource< Iterator > &&, ChunkedRangeSource< Iterator > >
typedef RangeSource< Iterator > && ValueType
 
typedef std::decay< RangeSource< Iterator > && >::type StorageType
 
- Static Public Attributes inherited from folly::gen::GenImpl< RangeSource< Iterator > &&, ChunkedRangeSource< Iterator > >
static constexpr bool infinite
 
- Protected Member Functions inherited from folly::gen::GenImpl< RangeSource< Iterator > &&, ChunkedRangeSource< Iterator > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Iterator>
class folly::gen::detail::ChunkedRangeSource< Iterator >

ChunkedRangeSource - For slicing up ranges into a sequence of chunks given a maximum chunk size.

Usually used through the 'chunked' helper, like:

int n = chunked(values) | parallel // each thread processes a chunk | concat // but can still process values one at a time | filter(isPrime) | atomic_count;

Definition at line 397 of file Parallel-inl.h.

Constructor & Destructor Documentation

template<class Iterator >
folly::gen::detail::ChunkedRangeSource< Iterator >::ChunkedRangeSource ( )
default
template<class Iterator >
folly::gen::detail::ChunkedRangeSource< Iterator >::ChunkedRangeSource ( int  chunkSize,
Range< Iterator >  range 
)
inline

Definition at line 404 of file Parallel-inl.h.

405  : chunkSize_(chunkSize), range_(std::move(range)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class Iterator >
template<class Handler >
bool folly::gen::detail::ChunkedRangeSource< Iterator >::apply ( Handler &&  handler) const
inline

Definition at line 408 of file Parallel-inl.h.

References handler(), folly::gen::move, and range_.

408  {
409  auto remaining = range_;
410  while (!remaining.empty()) {
411  auto chunk = remaining.subpiece(0, chunkSize_);
412  remaining.advance(chunk.size());
413  auto gen = RangeSource<Iterator>(chunk);
414  if (!handler(std::move(gen))) {
415  return false;
416  }
417  }
418  return true;
419  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void advance(size_type n)
Definition: Range.h:672
void handler(int, siginfo_t *, void *)
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686

Member Data Documentation

template<class Iterator >
int folly::gen::detail::ChunkedRangeSource< Iterator >::chunkSize_
private

Definition at line 399 of file Parallel-inl.h.

template<class Iterator >
Range<Iterator> folly::gen::detail::ChunkedRangeSource< Iterator >::range_
private

Definition at line 400 of file Parallel-inl.h.


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