proxygen
folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > Class Template Reference

#include <Parallel-inl.h>

Inheritance diagram for folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >:
folly::gen::GenImpl< OutputDecayed &&, Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > > folly::gen::FBounded< Self >

Classes

class  Executor
 
class  Puller
 
class  Pusher
 

Public Member Functions

 Generator (Source source, Ops ops, size_t threads)
 
template<class Handler >
bool apply (Handler &&handler) const
 
template<class Body >
void foreach (Body &&body) const
 
- Public Member Functions inherited from folly::gen::GenImpl< OutputDecayed &&, Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > >
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 Types

using InQueue = ClosableMPMCQueue< InputDecayed >
 
using OutQueue = ClosableMPMCQueue< OutputDecayed >
 

Private Attributes

Source source_
 
Ops ops_
 
size_t threads_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< OutputDecayed &&, Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > >
typedef OutputDecayed && ValueType
 
typedef std::decay< OutputDecayed && >::type StorageType
 
- Static Public Attributes inherited from folly::gen::GenImpl< OutputDecayed &&, Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > >
static constexpr bool infinite
 
- Protected Member Functions inherited from folly::gen::GenImpl< OutputDecayed &&, Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Ops>
template<class Input, class Source, class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
class folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >

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

Member Typedef Documentation

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
using folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::InQueue = ClosableMPMCQueue<InputDecayed>
private

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

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
using folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::OutQueue = ClosableMPMCQueue<OutputDecayed>
private

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

Constructor & Destructor Documentation

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Generator ( Source  source,
Ops  ops,
size_t  threads 
)
inline

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

306  : source_(std::move(source)),
307  ops_(std::move(ops)),
308  threads_(
309  threads
310  ? threads
311  : size_t(std::max<long>(1, sysconf(_SC_NPROCESSORS_CONF)))) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< std::thread::id > threads
const int ops

Member Function Documentation

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
template<class Handler >
bool folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::apply ( Handler &&  handler) const
inline

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

References folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::closeInputProducer(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::closeOutputConsumer(), folly::pushmi::executor, handler(), folly::gen::move, gmock_output_test::output, folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::readUnlessClosed(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::readUnlessEmpty(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::writeUnlessClosed(), and folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::writeUnlessFull().

314  {
315  Executor<false> executor(threads_, &ops_);
316  bool more = true;
317  source_.apply([&](Input input) {
318  if (executor.writeUnlessFull(std::forward<Input>(input))) {
319  return true;
320  }
321  OutputDecayed output;
322  while (executor.readUnlessEmpty(output)) {
323  if (!handler(std::move(output))) {
324  more = false;
325  return false;
326  }
327  }
328  if (!executor.writeUnlessClosed(std::forward<Input>(input))) {
329  return false;
330  }
331  return true;
332  });
333  executor.closeInputProducer();
334 
335  if (more) {
336  OutputDecayed output;
337  while (executor.readUnlessClosed(output)) {
338  if (!handler(std::move(output))) {
339  more = false;
340  break;
341  }
342  }
343  }
344  executor.closeOutputConsumer();
345 
346  return more;
347  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
void handler(int, siginfo_t *, void *)
template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
template<class Body >
void folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::foreach ( Body &&  body) const
inline

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

References folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::closeInputProducer(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::closeOutputConsumer(), folly::pushmi::executor, folly::gen::move, gmock_output_test::output, folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::readUnlessClosed(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::readUnlessEmpty(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::writeUnlessClosed(), and folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::Executor< all >::writeUnlessFull().

350  {
351  Executor<true> executor(threads_, &ops_);
352  source_.foreach([&](Input input) {
353  if (executor.writeUnlessFull(std::forward<Input>(input))) {
354  return;
355  }
356  OutputDecayed output;
357  while (executor.readUnlessEmpty(output)) {
358  body(std::move(output));
359  }
360  CHECK(executor.writeUnlessClosed(std::forward<Input>(input)));
361  });
362  executor.closeInputProducer();
363 
364  OutputDecayed output;
365  while (executor.readUnlessClosed(output)) {
366  body(std::move(output));
367  }
368  executor.closeOutputConsumer();
369  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor

Member Data Documentation

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
Ops folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::ops_
private

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

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
Source folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::source_
private

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

template<class Ops >
template<class Input , class Source , class InputDecayed = typename std::decay<Input>::type, class Composed = decltype(std::declval<Ops>().compose(Empty<InputDecayed&&>())), class Output = typename Composed::ValueType, class OutputDecayed = typename std::decay<Output>::type>
size_t folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >::threads_
private

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


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