proxygen
then_execute_2.cpp File Reference
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <futures.h>
#include <futures_static_thread_pool.h>
#include <atomic>
#include <functional>
#include <memory>
#include <thread>
#include <utility>
#include <folly/experimental/pushmi/examples/pool.h>
#include <folly/experimental/pushmi/o/just.h>
#include <folly/experimental/pushmi/o/transform.h>
#include <folly/experimental/pushmi/o/via.h>
#include <folly/experimental/pushmi/strand.h>

Go to the source code of this file.

Classes

struct  inline_executor
 

Namespaces

 p1054
 
 p1055
 

Functions

template<class T , class Executor >
std::pair< std::experimental::standard_promise< T >, std::experimental::standard_future< T, std::decay_t< Executor > > > p1054::make_promise_contract (const Executor &e)
 
template<class Executor , class Function , class Future >
std::experimental::standard_future< std::result_of_t< Function(std::decay_t< typename std::decay_t< Future >::value_type > &&)>, std::decay_t< Executor > > p1054::then_execute (Executor &&e, Function &&f, Future &&pred)
 
template<class Executor , class Function , class Future >
auto p1055::then_execute (Executor &&e, Function &&f, Future &&pred)
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 113 of file then_execute_2.cpp.

References f, folly::pushmi::operators::just, max, folly::gen::move, p1054::then_execute(), p1055::then_execute(), and v.

113  {
114  mi::pool p{std::max(1u, std::thread::hardware_concurrency())};
115 
116  std::experimental::futures_static_thread_pool sp{
117  std::max(1u, std::thread::hardware_concurrency())};
118 
119  auto pc = p1054::make_promise_contract<int>(inline_executor{});
120  auto& pr = std::get<0>(pc);
121  auto& r = std::get<1>(pc);
122  auto f = p1054::then_execute(
123  sp.executor(), [](int v) { return v * 2; }, std::move(r));
124  pr.set_value(42);
125  f.get();
126 
127  p1055::then_execute(p.executor(), [](int v) { return v * 2; }, op::just(21)) |
128  op::get<int>;
129 
130  sp.stop();
131  sp.wait();
132  p.stop();
133  p.wait();
134 
135  std::cout << "OK" << std::endl;
136 }
propagate_const< T > pc
auto f
auto v
LogLevel max
Definition: LogLevel.cpp:31
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::experimental::standard_future< std::result_of_t< Function(std::decay_t< typename std::decay_t< Future >::value_type > &&)>, std::decay_t< Executor > > then_execute(Executor &&e, Function &&f, Future &&pred)
auto then_execute(Executor &&e, Function &&f, Future &&pred)
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::just_fn just