22 #include <futures_static_thread_pool.h> 50 template <
class Function>
54 constexpr
bool query(std::experimental::execution::oneway_t) {
57 constexpr
bool query(std::experimental::execution::twoway_t) {
60 constexpr
bool query(std::experimental::execution::single_t) {
73 template <
class T,
class Executor>
75 std::experimental::standard_promise<T>,
76 std::experimental::standard_future<T, std::decay_t<Executor>>>
78 std::experimental::standard_promise<T> promise;
80 return {promise, promise.get_future(
std::move(ex))};
83 template <
class Executor,
class Function,
class Future>
84 std::experimental::standard_future<
86 Function(std::decay_t<
typename std::decay_t<Future>::value_type>&&)>,
87 std::decay_t<Executor>>
89 using V = std::decay_t<typename std::decay_t<Future>::value_type>;
90 using T = std::result_of_t<Function(V &&)>;
91 auto pc = make_promise_contract<T>(e);
92 auto p = std::get<0>(
pc);
93 auto r = std::get<1>(
pc);
94 ((Future &&) pred).then([e, p,
f](V
v)
mutable {
95 e.execute([p,
f, v]()
mutable { p.set_value(
f(v)); });
105 template <
class Executor,
class Function,
class Future>
116 std::experimental::futures_static_thread_pool sp{
117 std::max(1u, std::thread::hardware_concurrency())};
120 auto& pr = std::get<0>(
pc);
121 auto& r = std::get<1>(
pc);
123 sp.executor(), [](
int v) {
return v * 2; },
std::move(r));
135 std::cout <<
"OK" << std::endl;
requires Invocable< ExecutorFactory & > &&Executor< invoke_result_t< ExecutorFactory & > > &&ConcurrentSequence< invoke_result_t< ExecutorFactory & > > auto strands(ExecutorFactory ef)
std::pair< std::experimental::standard_promise< T >, std::experimental::standard_future< T, std::decay_t< Executor > > > make_promise_contract(const Executor &e)
constexpr detail::Map< Move > move
void execute(Function f) const noexcept
friend bool operator==(const inline_executor &, const inline_executor &) noexcept
friend bool operator!=(const inline_executor &, const inline_executor &) noexcept
constexpr bool query(std::experimental::execution::oneway_t)
requires E e noexcept(noexcept(s.error(std::move(e))))
PUSHMI_INLINE_VAR constexpr detail::transform_fn transform
PUSHMI_INLINE_VAR constexpr detail::via_fn via
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)
constexpr bool query(std::experimental::execution::single_t)
constexpr bool query(std::experimental::execution::twoway_t)
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::just_fn just