Commit b5df374b authored by Kirk Shoop's avatar Kirk Shoop Committed by Facebook Github Bot

move pushmi into folly namespace

Summary:
put pushmi inside the folly namespace.

NOTE: we discussed in the team and decided that we preferred to have a sub-namespace for pushmi

Reviewed By: yfeldblum

Differential Revision: D10455165

fbshipit-source-id: d0131d96172a14746971e2de7dbac7bb10604229
parent eb20fbbe
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <folly/experimental/pushmi/pool.h> #include <folly/experimental/pushmi/pool.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
template <class R> template <class R>
struct countdown { struct countdown {
...@@ -496,7 +496,8 @@ NONIUS_BENCHMARK("trampoline virtual derecursion 1'000", [](nonius::chronometer ...@@ -496,7 +496,8 @@ NONIUS_BENCHMARK("trampoline virtual derecursion 1'000", [](nonius::chronometer
auto tr = mi::trampoline(); auto tr = mi::trampoline();
using TR = decltype(tr); using TR = decltype(tr);
auto single = countdownsingle{counter}; auto single = countdownsingle{counter};
std::function<void(mi::any_executor_ref<>)> recurse{[&](auto exec){::pushmi::set_value(single, exec);}}; std::function<void(mi::any_executor_ref<>)> recurse{
[&](auto exec) { ::folly::pushmi::set_value(single, exec); }};
meter.measure([&]{ meter.measure([&]{
counter.store(1'000); counter.store(1'000);
tr | op::submit([&](auto exec) { recurse(exec); }); tr | op::submit([&](auto exec) { recurse(exec); });
......
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <chrono> #include <chrono>
#include <cstdint> #include <cstdint>
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
#include <utility> #include <utility>
#include <folly/experimental/pushmi/concepts.h> #include <folly/experimental/pushmi/concepts.h>
#include <folly/experimental/pushmi/traits.h>
#include <folly/experimental/pushmi/detail/functional.h> #include <folly/experimental/pushmi/detail/functional.h>
#include <folly/experimental/pushmi/traits.h>
namespace folly {
namespace pushmi { namespace pushmi {
template<class T> template<class T>
...@@ -65,7 +66,8 @@ template<> ...@@ -65,7 +66,8 @@ template<>
struct construct_deduced<flow_many_sender>; struct construct_deduced<flow_many_sender>;
template <template <class...> class T, class... AN> template <template <class...> class T, class... AN>
using deduced_type_t = pushmi::invoke_result_t<construct_deduced<T>, AN...>; using deduced_type_t =
::folly::pushmi::invoke_result_t<construct_deduced<T>, AN...>;
struct ignoreVF { struct ignoreVF {
PUSHMI_TEMPLATE(class... VN) PUSHMI_TEMPLATE(class... VN)
...@@ -114,10 +116,10 @@ struct priorityZeroF { ...@@ -114,10 +116,10 @@ struct priorityZeroF {
struct passDVF { struct passDVF {
PUSHMI_TEMPLATE(class Data, class... VN) PUSHMI_TEMPLATE(class Data, class... VN)
(requires requires ( (requires requires (
::pushmi::set_value(std::declval<Data&>(), std::declval<VN>()...) set_value(std::declval<Data&>(), std::declval<VN>()...)
) && Receiver<Data>) ) && Receiver<Data>)
void operator()(Data& out, VN&&... vn) const { void operator()(Data& out, VN&&... vn) const {
::pushmi::set_value(out, (VN&&) vn...); set_value(out, (VN&&) vn...);
} }
}; };
...@@ -125,7 +127,7 @@ struct passDEF { ...@@ -125,7 +127,7 @@ struct passDEF {
PUSHMI_TEMPLATE(class E, class Data) PUSHMI_TEMPLATE(class E, class Data)
(requires ReceiveError<Data, E>) (requires ReceiveError<Data, E>)
void operator()(Data& out, E e) const noexcept { void operator()(Data& out, E e) const noexcept {
::pushmi::set_error(out, e); set_error(out, e);
} }
}; };
...@@ -133,17 +135,17 @@ struct passDDF { ...@@ -133,17 +135,17 @@ struct passDDF {
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires Receiver<Data>) (requires Receiver<Data>)
void operator()(Data& out) const { void operator()(Data& out) const {
::pushmi::set_done(out); set_done(out);
} }
}; };
struct passDStrtF { struct passDStrtF {
PUSHMI_TEMPLATE(class Up, class Data) PUSHMI_TEMPLATE(class Up, class Data)
(requires requires ( (requires requires (
::pushmi::set_starting(std::declval<Data&>(), std::declval<Up>()) set_starting(std::declval<Data&>(), std::declval<Up>())
) && Receiver<Data>) ) && Receiver<Data>)
void operator()(Data& out, Up&& up) const { void operator()(Data& out, Up&& up) const {
::pushmi::set_starting(out, (Up&&) up); set_starting(out, (Up&&) up);
} }
}; };
...@@ -151,18 +153,18 @@ struct passDEXF { ...@@ -151,18 +153,18 @@ struct passDEXF {
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires Sender<Data>) (requires Sender<Data>)
auto operator()(Data& in) const noexcept { auto operator()(Data& in) const noexcept {
return ::pushmi::executor(in); return executor(in);
} }
}; };
struct passDSF { struct passDSF {
template <class Data, class Out> template <class Data, class Out>
void operator()(Data& in, Out out) { void operator()(Data& in, Out out) {
::pushmi::submit(in, std::move(out)); submit(in, std::move(out));
} }
template <class Data, class TP, class Out> template <class Data, class TP, class Out>
void operator()(Data& in, TP at, Out out) { void operator()(Data& in, TP at, Out out) {
::pushmi::submit(in, std::move(at), std::move(out)); submit(in, std::move(at), std::move(out));
} }
}; };
...@@ -170,7 +172,7 @@ struct passDNF { ...@@ -170,7 +172,7 @@ struct passDNF {
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires TimeSender<Data>) (requires TimeSender<Data>)
auto operator()(Data& in) const noexcept { auto operator()(Data& in) const noexcept {
return ::pushmi::now(in); return ::folly::pushmi::now(in);
} }
}; };
...@@ -178,7 +180,7 @@ struct passDZF { ...@@ -178,7 +180,7 @@ struct passDZF {
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires ConstrainedSender<Data>) (requires ConstrainedSender<Data>)
auto operator()(Data& in) const noexcept { auto operator()(Data& in) const noexcept {
return ::pushmi::top(in); return ::folly::pushmi::top(in);
} }
}; };
...@@ -329,3 +331,4 @@ auto on_now(Fn fn) -> on_now_fn<Fn> { ...@@ -329,3 +331,4 @@ auto on_now(Fn fn) -> on_now_fn<Fn> {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/extension_points.h> #include <folly/experimental/pushmi/extension_points.h>
#include <folly/experimental/pushmi/forwards.h> #include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/properties.h> #include <folly/experimental/pushmi/properties.h>
namespace folly {
namespace pushmi { namespace pushmi {
// traits & tags // traits & tags
...@@ -285,14 +286,14 @@ PUSHMI_CONCEPT_DEF( ...@@ -285,14 +286,14 @@ PUSHMI_CONCEPT_DEF(
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class... PropertyN)(concept Receiver)(R, PropertyN...), template(class R, class... PropertyN)(concept Receiver)(R, PropertyN...),
requires(R& r)( requires(R& r)(
::pushmi::set_done(r), set_done(r),
::pushmi::set_error(r, std::exception_ptr{})) && set_error(r, std::exception_ptr{})) &&
SemiMovable<R> && property_query_v<R, PropertyN...> && SemiMovable<R> && property_query_v<R, PropertyN...> &&
is_receiver_v<R> && !is_sender_v<R>); is_receiver_v<R> && !is_sender_v<R>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class... VN)(concept ReceiveValue)(R, VN...), template(class R, class... VN)(concept ReceiveValue)(R, VN...),
requires(R& r)(::pushmi::set_value(r, std::declval<VN&&>()...)) && requires(R& r)(set_value(r, std::declval<VN&&>()...)) &&
Receiver<R> && Receiver<R> &&
// GCC w/-fconcepts ICE on SemiMovable<VN>... // GCC w/-fconcepts ICE on SemiMovable<VN>...
True<> // And<SemiMovable<VN>...> True<> // And<SemiMovable<VN>...>
...@@ -300,28 +301,28 @@ PUSHMI_CONCEPT_DEF( ...@@ -300,28 +301,28 @@ PUSHMI_CONCEPT_DEF(
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class E = std::exception_ptr)(concept ReceiveError)(R, E), template(class R, class E = std::exception_ptr)(concept ReceiveError)(R, E),
requires(R& r, E&& e)(::pushmi::set_error(r, (E &&) e)) && Receiver<R> && requires(R& r, E&& e)(set_error(r, (E &&) e)) && Receiver<R> &&
SemiMovable<E>); SemiMovable<E>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)(concept Sender)(D, PropertyN...), template(class D, class... PropertyN)(concept Sender)(D, PropertyN...),
requires(D& d)( requires(D& d)(
::pushmi::executor(d), executor(d),
requires_<Executor<decltype(::pushmi::executor(d))>>) && requires_<Executor<decltype(executor(d))>>) &&
SemiMovable<D> && Cardinality<D> && property_query_v<D, PropertyN...> && SemiMovable<D> && Cardinality<D> && property_query_v<D, PropertyN...> &&
is_sender_v<D> && !is_receiver_v<D>); is_sender_v<D> && !is_receiver_v<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN)(
concept SenderTo)(D, S, PropertyN...), concept SenderTo)(D, S, PropertyN...),
requires(D& d, S&& s)(::pushmi::submit(d, (S &&) s)) && Sender<D> && requires(D& d, S&& s)(submit(d, (S &&) s)) && Sender<D> &&
Receiver<S> && property_query_v<D, PropertyN...>); Receiver<S> && property_query_v<D, PropertyN...>);
template <class D> template <class D>
PUSHMI_PP_CONSTRAINED_USING( PUSHMI_PP_CONSTRAINED_USING(
Sender<D>, Sender<D>,
executor_t =, executor_t =,
decltype(::pushmi::executor(std::declval<D&>()))); decltype(executor(std::declval<D&>())));
// add concepts to support cancellation // add concepts to support cancellation
// //
...@@ -342,7 +343,7 @@ PUSHMI_CONCEPT_DEF( ...@@ -342,7 +343,7 @@ PUSHMI_CONCEPT_DEF(
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class Up)(concept FlowUpTo)(R, Up), template(class R, class Up)(concept FlowUpTo)(R, Up),
requires(R& r, Up&& up)(::pushmi::set_starting(r, (Up &&) up)) && Flow<R>); requires(R& r, Up&& up)(set_starting(r, (Up &&) up)) && Flow<R>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class S, class... PropertyN)(concept FlowSender)(S, PropertyN...), template(class S, class... PropertyN)(concept FlowSender)(S, PropertyN...),
...@@ -366,14 +367,14 @@ PUSHMI_CONCEPT_DEF( ...@@ -366,14 +367,14 @@ PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)( template(class D, class... PropertyN)(
concept ConstrainedSender)(D, PropertyN...), concept ConstrainedSender)(D, PropertyN...),
requires(D& d)( requires(D& d)(
::pushmi::top(d), top(d),
requires_<Regular<decltype(::pushmi::top(d))>>) && requires_<Regular<decltype(top(d))>>) &&
Sender<D> && property_query_v<D, PropertyN...> && Constrained<D>); Sender<D> && property_query_v<D, PropertyN...> && Constrained<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN)(
concept ConstrainedSenderTo)(D, S, PropertyN...), concept ConstrainedSenderTo)(D, S, PropertyN...),
requires(D& d, S&& s)(::pushmi::submit(d, ::pushmi::top(d), (S &&) s)) && requires(D& d, S&& s)(submit(d, top(d), (S &&) s)) &&
ConstrainedSender<D> && property_query_v<D, PropertyN...> && ConstrainedSender<D> && property_query_v<D, PropertyN...> &&
Receiver<S>); Receiver<S>);
...@@ -381,14 +382,14 @@ template <class D> ...@@ -381,14 +382,14 @@ template <class D>
PUSHMI_PP_CONSTRAINED_USING( PUSHMI_PP_CONSTRAINED_USING(
ConstrainedSender<D>, ConstrainedSender<D>,
constraint_t =, constraint_t =,
decltype(::pushmi::top(std::declval<D&>()))); decltype(top(std::declval<D&>())));
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)(concept TimeSender)(D, PropertyN...), template(class D, class... PropertyN)(concept TimeSender)(D, PropertyN...),
requires(D& d)( requires(D& d)(
::pushmi::now(d), now(d),
requires_< requires_<
Regular<decltype(::pushmi::now(d) + std::chrono::seconds(1))>>) && Regular<decltype(now(d) + std::chrono::seconds(1))>>) &&
ConstrainedSender<D, PropertyN...> && Time<D>); ConstrainedSender<D, PropertyN...> && Time<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
...@@ -400,6 +401,7 @@ template <class D> ...@@ -400,6 +401,7 @@ template <class D>
PUSHMI_PP_CONSTRAINED_USING( PUSHMI_PP_CONSTRAINED_USING(
TimeSender<D>, TimeSender<D>,
time_point_t =, time_point_t =,
decltype(::pushmi::now(std::declval<D&>()))); decltype(now(std::declval<D&>())));
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/inline.h> #include <folly/experimental/pushmi/inline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class CV, class... VN> template <class E, class CV, class... VN>
...@@ -54,16 +55,15 @@ class any_constrained_single_sender { ...@@ -54,16 +55,15 @@ class any_constrained_single_sender {
delete static_cast<Wrapped const*>(src.pobj_); delete static_cast<Wrapped const*>(src.pobj_);
} }
static CV top(data& src) { static CV top(data& src) {
return ::pushmi::top(*static_cast<Wrapped*>(src.pobj_)); return ::folly::pushmi::top(*static_cast<Wrapped*>(src.pobj_));
} }
static any_constrained_executor<E, CV> executor(data& src) { static any_constrained_executor<E, CV> executor(data& src) {
return any_constrained_executor<E, CV>{::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))}; return any_constrained_executor<E, CV>{
executor(*static_cast<Wrapped*>(src.pobj_))};
} }
static void submit(data& src, CV at, any_receiver<E, VN...> out) { static void submit(data& src, CV at, any_receiver<E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>(src.pobj_), *static_cast<Wrapped*>(src.pobj_), std::move(at), std::move(out));
std::move(at),
std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::top, s::executor, s::submit}; static const vtable vtbl{s::op, s::top, s::executor, s::submit};
...@@ -81,13 +81,14 @@ class any_constrained_single_sender { ...@@ -81,13 +81,14 @@ class any_constrained_single_sender {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static CV top(data& src) { static CV top(data& src) {
return ::pushmi::top(*static_cast<Wrapped*>((void*)src.buffer_)); return ::folly::pushmi::top(*static_cast<Wrapped*>((void*)src.buffer_));
} }
static any_constrained_executor<E, CV> executor(data& src) { static any_constrained_executor<E, CV> executor(data& src) {
return any_constrained_executor<E, CV>{::pushmi::executor(*static_cast<Wrapped*>((void*)src.buffer_))}; return any_constrained_executor<E, CV>{
executor(*static_cast<Wrapped*>((void*)src.buffer_))};
} }
static void submit(data& src, CV cv, any_receiver<E, VN...> out) { static void submit(data& src, CV cv, any_receiver<E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>((void*)src.buffer_), *static_cast<Wrapped*>((void*)src.buffer_),
std::move(cv), std::move(cv),
std::move(out)); std::move(out));
...@@ -289,3 +290,4 @@ struct construct_deduced<constrained_single_sender> ...@@ -289,3 +290,4 @@ struct construct_deduced<constrained_single_sender>
: make_constrained_single_sender_fn {}; : make_constrained_single_sender_fn {};
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <functional> #include <functional>
#include <folly/experimental/pushmi/detail/concept_def.h> #include <folly/experimental/pushmi/detail/concept_def.h>
namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_INLINE_VAR constexpr struct invoke_fn { PUSHMI_INLINE_VAR constexpr struct invoke_fn {
...@@ -43,13 +44,13 @@ PUSHMI_INLINE_VAR constexpr struct invoke_fn { ...@@ -43,13 +44,13 @@ PUSHMI_INLINE_VAR constexpr struct invoke_fn {
template <class F, class... As> template <class F, class... As>
using invoke_result_t = using invoke_result_t =
decltype(pushmi::invoke(std::declval<F>(), std::declval<As>()...)); decltype(folly::pushmi::invoke(std::declval<F>(), std::declval<As>()...));
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template (class F, class... Args) template (class F, class... Args)
(concept Invocable)(F, Args...), (concept Invocable)(F, Args...),
requires(F&& f) ( requires(F&& f) (
pushmi::invoke((F &&) f, std::declval<Args>()...) ::folly::pushmi::invoke((F &&) f, std::declval<Args>()...)
) )
); );
...@@ -57,9 +58,10 @@ PUSHMI_CONCEPT_DEF( ...@@ -57,9 +58,10 @@ PUSHMI_CONCEPT_DEF(
template (class F, class... Args) template (class F, class... Args)
(concept NothrowInvocable)(F, Args...), (concept NothrowInvocable)(F, Args...),
requires(F&& f) ( requires(F&& f) (
requires_<noexcept(pushmi::invoke((F &&) f, std::declval<Args>()...))> requires_<noexcept(::folly::pushmi::invoke((F &&) f, std::declval<Args>()...))>
) && ) &&
Invocable<F, Args...> Invocable<F, Args...>
); );
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
// Usage: // Usage:
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#define PUSHMI_STRIP(...) __VA_ARGS__ #define PUSHMI_STRIP(...) __VA_ARGS__
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
struct id_fn { struct id_fn {
...@@ -94,14 +95,16 @@ struct id_fn { ...@@ -94,14 +95,16 @@ struct id_fn {
return (T&&) t; return (T&&) t;
} }
}; };
} } // namespace detail
} } // namespace pushmi
} // namespace folly
#if __cpp_if_constexpr >= 201606 #if __cpp_if_constexpr >= 201606
#define PUSHMI_IF_CONSTEXPR(LIST)\ #define PUSHMI_IF_CONSTEXPR(LIST) \
if constexpr (::pushmi::detail::id_fn id = {}) {} \ if constexpr (::folly::pushmi::detail::id_fn id = {}) { \
else if constexpr PUSHMI_EVAL(PUSHMI_IF_CONSTEXPR_ELSE_, PUSHMI_IF_CONSTEXPR_IF_ LIST) } else if constexpr \
PUSHMI_EVAL(PUSHMI_IF_CONSTEXPR_ELSE_, PUSHMI_IF_CONSTEXPR_IF_ LIST)
#define PUSHMI_IF_CONSTEXPR_RETURN(LIST)\ #define PUSHMI_IF_CONSTEXPR_RETURN(LIST)\
PUSHMI_PP_IGNORE_SHADOW_BEGIN \ PUSHMI_PP_IGNORE_SHADOW_BEGIN \
...@@ -133,8 +136,8 @@ struct id_fn { ...@@ -133,8 +136,8 @@ struct id_fn {
return PUSHMI_EVAL(PUSHMI_IF_CONSTEXPR_ELSE_, PUSHMI_IF_CONSTEXPR_IF_ LIST)\ return PUSHMI_EVAL(PUSHMI_IF_CONSTEXPR_ELSE_, PUSHMI_IF_CONSTEXPR_IF_ LIST)\
/**/ /**/
#define PUSHMI_IF_CONSTEXPR_IF_(...) \ #define PUSHMI_IF_CONSTEXPR_IF_(...) \
(::pushmi::detail::select<bool(__VA_ARGS__)>() ->* PUSHMI_IF_CONSTEXPR_THEN_ \ (::folly::pushmi::detail::select<bool(__VA_ARGS__)>() ->* PUSHMI_IF_CONSTEXPR_THEN_ \
/**/ /**/
#define PUSHMI_IF_CONSTEXPR_THEN_(...) \ #define PUSHMI_IF_CONSTEXPR_THEN_(...) \
...@@ -149,6 +152,7 @@ struct id_fn { ...@@ -149,6 +152,7 @@ struct id_fn {
([&](PUSHMI_MAYBE_UNUSED auto id)mutable->decltype(auto){__VA_ARGS__});\ ([&](PUSHMI_MAYBE_UNUSED auto id)mutable->decltype(auto){__VA_ARGS__});\
/**/ /**/
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -168,12 +172,12 @@ struct select { ...@@ -168,12 +172,12 @@ struct select {
}; };
template <class T> template <class T>
constexpr auto operator->*(T&& t) constexpr auto operator->*(T&& t)
-> eat_return<decltype(t(::pushmi::detail::id_fn{}))> { -> eat_return<decltype(t(::folly::pushmi::detail::id_fn{}))> {
return {t(::pushmi::detail::id_fn{})}; return {t(::folly::pushmi::detail::id_fn{})};
} }
template <class T> template <class T>
constexpr auto operator->*(T&& t) const -> eat { constexpr auto operator->*(T&& t) const -> eat {
return t(::pushmi::detail::id_fn{}), void(), eat{}; return t(::folly::pushmi::detail::id_fn{}), void(), eat{};
} }
}; };
...@@ -182,7 +186,7 @@ struct select<false> { ...@@ -182,7 +186,7 @@ struct select<false> {
struct eat { struct eat {
template <class T> template <class T>
constexpr auto operator->*(T&& t) -> decltype(auto) { constexpr auto operator->*(T&& t) -> decltype(auto) {
return t(::pushmi::detail::id_fn{}); return t(::folly::pushmi::detail::id_fn{});
} }
}; };
template <class T> template <class T>
...@@ -192,4 +196,5 @@ struct select<false> { ...@@ -192,4 +196,5 @@ struct select<false> {
}; };
} // namespace detail } // namespace detail
} // namespace pushmi } // namespace pushmi
} // namespace folly
#endif #endif
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#if __cpp_lib_optional >= 201606 #if __cpp_lib_optional >= 201606
#include <optional> // @manual #include <optional> // @manual
#endif #endif
#include <type_traits> #include <type_traits>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
#if __cpp_lib_optional >= 201606 #if __cpp_lib_optional >= 201606
...@@ -137,3 +138,4 @@ struct opt { ...@@ -137,3 +138,4 @@ struct opt {
} // namespace detail } // namespace detail
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/forwards.h> #include <folly/experimental/pushmi/forwards.h>
namespace folly {
namespace pushmi { namespace pushmi {
// template <class T, class Dual> // template <class T, class Dual>
...@@ -313,3 +314,4 @@ locked_shared_entangled_pair<T, Dual> lock_both(shared_entangled<T, Dual>& e) { ...@@ -313,3 +314,4 @@ locked_shared_entangled_pair<T, Dual> lock_both(shared_entangled<T, Dual>& e) {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace operators { namespace operators {
...@@ -62,3 +63,4 @@ PUSHMI_INLINE_VAR constexpr struct bulk_fn { ...@@ -62,3 +63,4 @@ PUSHMI_INLINE_VAR constexpr struct bulk_fn {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <folly/experimental/pushmi/o/via.h> #include <folly/experimental/pushmi/o/via.h>
#include <folly/experimental/pushmi/strand.h> #include <folly/experimental/pushmi/strand.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
struct f_t {}; struct f_t {};
f_t f() { f_t f() {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// https://godbolt.org/g/rVLMTu // https://godbolt.org/g/rVLMTu
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
// three models of submission deferral // three models of submission deferral
// (none of these use an executor, they are all running // (none of these use an executor, they are all running
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <folly/experimental/pushmi/o/tap.h> #include <folly/experimental/pushmi/o/tap.h>
#include <folly/experimental/pushmi/o/transform.h> #include <folly/experimental/pushmi/o/transform.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
template <class Io> template <class Io>
auto io_operation(Io io) { auto io_operation(Io io) {
......
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/examples/bulk.h> #include <folly/experimental/pushmi/examples/bulk.h>
#include <folly/experimental/pushmi/o/just.h> #include <folly/experimental/pushmi/o/just.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_INLINE_VAR constexpr struct for_each_fn { PUSHMI_INLINE_VAR constexpr struct for_each_fn {
...@@ -58,3 +59,4 @@ PUSHMI_INLINE_VAR constexpr struct for_each_fn { ...@@ -58,3 +59,4 @@ PUSHMI_INLINE_VAR constexpr struct for_each_fn {
} for_each{}; } for_each{};
} // namespace pushmi } // namespace pushmi
} // namespace folly
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/experimental/pushmi/examples/for_each.h> #include <folly/experimental/pushmi/examples/for_each.h>
#include <folly/experimental/pushmi/examples/pool.h> #include <folly/experimental/pushmi/examples/pool.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
template <class Executor, class Allocator = std::allocator<char>> template <class Executor, class Allocator = std::allocator<char>>
auto naive_executor_bulk_target(Executor e, Allocator a = Allocator{}) { auto naive_executor_bulk_target(Executor e, Allocator a = Allocator{}) {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <folly/experimental/pushmi/examples/for_each.h> #include <folly/experimental/pushmi/examples/for_each.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
auto inline_bulk_target() { auto inline_bulk_target() {
return [](auto init, return [](auto init,
......
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -33,16 +34,16 @@ struct no_fail_fn { ...@@ -33,16 +34,16 @@ struct no_fail_fn {
struct out_impl { struct out_impl {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>)auto operator()(Out out) const { (requires Receiver<Out>)auto operator()(Out out) const {
return ::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
std::move(out), ::pushmi::on_error(on_error_impl{})); std::move(out), ::folly::pushmi::on_error(on_error_impl{}));
} }
}; };
struct in_impl { struct in_impl {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>)auto operator()(In in) const { (requires Sender<In>)auto operator()(In in) const {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>(out_impl<In>{})); ::folly::pushmi::detail::submit_transform_out<In>(out_impl<In>{}));
} }
}; };
...@@ -59,3 +60,4 @@ PUSHMI_INLINE_VAR constexpr detail::no_fail_fn no_fail{}; ...@@ -59,3 +60,4 @@ PUSHMI_INLINE_VAR constexpr detail::no_fail_fn no_fail{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <experimental/thread_pool> // @manual #include <experimental/thread_pool> // @manual
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#define MAKE(x) make_##x #define MAKE(x) make_##x
#endif #endif
namespace folly {
namespace pushmi { namespace pushmi {
using std::experimental::static_thread_pool; using std::experimental::static_thread_pool;
...@@ -50,10 +51,10 @@ struct pool_executor { ...@@ -50,10 +51,10 @@ struct pool_executor {
return *this; return *this;
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>)void submit(Out out) const { (requires Receiver<Out>)
e.execute([e = *this, out = std::move(out)]() mutable { void submit(Out out) const {
::pushmi::set_value(out, e); e.execute(
}); [e = *this, out = std::move(out)]() mutable { set_value(out, e); });
} }
}; };
...@@ -78,3 +79,4 @@ class pool { ...@@ -78,3 +79,4 @@ class pool {
}; };
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/examples/bulk.h> #include <folly/experimental/pushmi/examples/bulk.h>
#include <folly/experimental/pushmi/o/just.h> #include <folly/experimental/pushmi/o/just.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_INLINE_VAR constexpr struct reduce_fn { PUSHMI_INLINE_VAR constexpr struct reduce_fn {
...@@ -59,3 +60,4 @@ PUSHMI_INLINE_VAR constexpr struct reduce_fn { ...@@ -59,3 +60,4 @@ PUSHMI_INLINE_VAR constexpr struct reduce_fn {
} reduce{}; } reduce{};
} // namespace pushmi } // namespace pushmi
} // namespace folly
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <folly/experimental/pushmi/examples/pool.h> #include <folly/experimental/pushmi/examples/pool.h>
#include <folly/experimental/pushmi/examples/reduce.h> #include <folly/experimental/pushmi/examples/reduce.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
template <class Executor, class Allocator = std::allocator<char>> template <class Executor, class Allocator = std::allocator<char>>
auto naive_executor_bulk_target(Executor e, Allocator a = Allocator{}) { auto naive_executor_bulk_target(Executor e, Allocator a = Allocator{}) {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <folly/experimental/pushmi/examples/reduce.h> #include <folly/experimental/pushmi/examples/reduce.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
auto inline_bulk_target() { auto inline_bulk_target() {
return [](auto init, return [](auto init,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <folly/experimental/pushmi/o/tap.h> #include <folly/experimental/pushmi/o/tap.h>
#include <folly/experimental/pushmi/o/transform.h> #include <folly/experimental/pushmi/o/transform.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
const bool setting_exists = false; const bool setting_exists = false;
...@@ -44,9 +44,9 @@ auto println = [](auto v) { std::cout << v << std::endl; }; ...@@ -44,9 +44,9 @@ auto println = [](auto v) { std::cout << v << std::endl; };
template <class T, class E = std::exception_ptr> template <class T, class E = std::exception_ptr>
auto concat = [](auto in) { auto concat = [](auto in) {
return mi::make_single_sender([in](auto out) mutable { return mi::make_single_sender([in](auto out) mutable {
::pushmi::submit(in, mi::make_receiver(out, [](auto out, auto v) { mi::submit(in, mi::make_receiver(out, [](auto out, auto v) {
::pushmi::submit(v, mi::any_receiver<E, T>(out)); mi::submit(v, mi::any_receiver<E, T>(out));
})); }));
}); });
}; };
......
...@@ -25,15 +25,15 @@ ...@@ -25,15 +25,15 @@
#include <folly/experimental/pushmi/o/switch_on_error.h> #include <folly/experimental/pushmi/o/switch_on_error.h>
#include <folly/experimental/pushmi/o/transform.h> #include <folly/experimental/pushmi/o/transform.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
// concat not yet implemented // concat not yet implemented
template <class T, class E = std::exception_ptr> template <class T, class E = std::exception_ptr>
auto concat = [](auto in) { auto concat = [](auto in) {
return mi::make_single_sender([in](auto out) mutable { return mi::make_single_sender([in](auto out) mutable {
::pushmi::submit(in, mi::make_receiver(out, [](auto out, auto v) { mi::submit(in, mi::make_receiver(out, [](auto out, auto v) {
::pushmi::submit(v, mi::any_receiver<E, T>(out)); mi::submit(v, mi::any_receiver<E, T>(out));
})); }));
}); });
}; };
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <folly/experimental/pushmi/o/via.h> #include <folly/experimental/pushmi/o/via.h>
#include <folly/experimental/pushmi/strand.h> #include <folly/experimental/pushmi/strand.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
struct inline_executor { struct inline_executor {
public: public:
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <folly/experimental/pushmi/o/transform.h> #include <folly/experimental/pushmi/o/transform.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
namespace p1054 { namespace p1054 {
// A promise refers to a promise and is associated with a future, // A promise refers to a promise and is associated with a future,
......
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,18 @@ ...@@ -14,11 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <folly/experimental/pushmi/concepts.h>
#include <folly/experimental/pushmi/extension_points.h>
#include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/traits.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
template <class T, template <class...> class C> template <class T, template <class...> class C>
...@@ -65,9 +71,9 @@ public: ...@@ -65,9 +71,9 @@ public:
" that accpets a value of type This and an error of type E"); " that accpets a value of type This and an error of type E");
struct s { struct s {
static void submit(void* pobj, void* s) { static void submit(void* pobj, void* s) {
return ::pushmi::submit( return ::folly::pushmi::submit(
*static_cast<Wrapped*>(pobj), *static_cast<Wrapped*>(pobj),
std::move(*static_cast<any_receiver<E,This>*>(s))); std::move(*static_cast<any_receiver<E, This>*>(s)));
} }
}; };
static const vtable vtbl{s::submit}; static const vtable vtbl{s::submit};
...@@ -215,13 +221,13 @@ public: ...@@ -215,13 +221,13 @@ public:
" that accpets a value of type This and an error of type E"); " that accpets a value of type This and an error of type E");
struct s { struct s {
static CV top(void* pobj) { static CV top(void* pobj) {
return ::pushmi::top(*static_cast<Wrapped*>(pobj)); return ::folly::pushmi::top(*static_cast<Wrapped*>(pobj));
} }
static void submit(void* pobj, CV cv, void* s) { static void submit(void* pobj, CV cv, void* s) {
return ::pushmi::submit( return ::folly::pushmi::submit(
*static_cast<Wrapped*>(pobj), *static_cast<Wrapped*>(pobj),
cv, cv,
std::move(*static_cast<any_receiver<E,This>*>(s))); std::move(*static_cast<any_receiver<E, This>*>(s)));
} }
}; };
static const vtable vtbl{s::top, s::submit}; static const vtable vtbl{s::top, s::submit};
...@@ -379,13 +385,13 @@ public: ...@@ -379,13 +385,13 @@ public:
" that accpets a value of type This and an error of type E"); " that accpets a value of type This and an error of type E");
struct s { struct s {
static TP now(void* pobj) { static TP now(void* pobj) {
return ::pushmi::now(*static_cast<Wrapped*>(pobj)); return ::folly::pushmi::now(*static_cast<Wrapped*>(pobj));
} }
static void submit(void* pobj, TP tp, void* s) { static void submit(void* pobj, TP tp, void* s) {
return ::pushmi::submit( return ::folly::pushmi::submit(
*static_cast<Wrapped*>(pobj), *static_cast<Wrapped*>(pobj),
tp, tp,
std::move(*static_cast<any_receiver<E,This>*>(s))); std::move(*static_cast<any_receiver<E, This>*>(s)));
} }
}; };
static const vtable vtbl{s::now, s::submit}; static const vtable vtbl{s::now, s::submit};
...@@ -503,3 +509,4 @@ any_time_executor(Wrapped) -> ...@@ -503,3 +509,4 @@ any_time_executor(Wrapped) ->
#endif #endif
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <future> #include <future>
#include <functional> #include <functional>
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <folly/experimental/pushmi/properties.h> #include <folly/experimental/pushmi/properties.h>
#include <folly/experimental/pushmi/traits.h> #include <folly/experimental/pushmi/traits.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace __adl { namespace __adl {
...@@ -376,3 +377,4 @@ struct property_set_traits<std::promise<void>> { ...@@ -376,3 +377,4 @@ struct property_set_traits<std::promise<void>> {
}; };
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/flow_receiver.h> #include <folly/experimental/pushmi/flow_receiver.h>
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class PE, class PV, class E, class... VN> template <class PE, class PV, class E, class... VN>
...@@ -51,10 +52,12 @@ class any_flow_many_sender { ...@@ -51,10 +52,12 @@ class any_flow_many_sender {
delete static_cast<Wrapped const*>(src.pobj_); delete static_cast<Wrapped const*>(src.pobj_);
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))}; return any_executor<E>{
::folly::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))};
} }
static void submit(data& src, any_flow_receiver<PE, PV, E, VN...> out) { static void submit(data& src, any_flow_receiver<PE, PV, E, VN...> out) {
::pushmi::submit(*static_cast<Wrapped*>(src.pobj_), std::move(out)); ::folly::pushmi::submit(
*static_cast<Wrapped*>(src.pobj_), std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::executor, s::submit}; static const vtable vtbl{s::op, s::executor, s::submit};
...@@ -72,12 +75,12 @@ class any_flow_many_sender { ...@@ -72,12 +75,12 @@ class any_flow_many_sender {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{::pushmi::executor(*static_cast<Wrapped*>((void*)src.buffer_))}; return any_executor<E>{::folly::pushmi::executor(
*static_cast<Wrapped*>((void*)src.buffer_))};
} }
static void submit(data& src, any_flow_receiver<PE, PV, E, VN...> out) { static void submit(data& src, any_flow_receiver<PE, PV, E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>((void*)src.buffer_), *static_cast<Wrapped*>((void*)src.buffer_), std::move(out));
std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::executor, s::submit}; static const vtable vtbl{s::op, s::executor, s::submit};
...@@ -246,3 +249,4 @@ struct construct_deduced<flow_many_sender> ...@@ -246,3 +249,4 @@ struct construct_deduced<flow_many_sender>
// } // }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class PE, class PV, class E, class... VN> template <class PE, class PV, class E, class... VN>
...@@ -55,16 +56,16 @@ class any_flow_receiver { ...@@ -55,16 +56,16 @@ class any_flow_receiver {
delete static_cast<Wrapped const*>(src.pobj_); delete static_cast<Wrapped const*>(src.pobj_);
} }
static void done(data& src) { static void done(data& src) {
::pushmi::set_done(*static_cast<Wrapped*>(src.pobj_)); set_done(*static_cast<Wrapped*>(src.pobj_));
} }
static void error(data& src, E e) noexcept { static void error(data& src, E e) noexcept {
::pushmi::set_error(*static_cast<Wrapped*>(src.pobj_), std::move(e)); set_error(*static_cast<Wrapped*>(src.pobj_), std::move(e));
} }
static void value(data& src, VN... vn) { static void value(data& src, VN... vn) {
::pushmi::set_value(*static_cast<Wrapped*>(src.pobj_), std::move(vn)...); set_value(*static_cast<Wrapped*>(src.pobj_), std::move(vn)...);
} }
static void starting(data& src, any_receiver<PE, PV> up) { static void starting(data& src, any_receiver<PE, PV> up) {
::pushmi::set_starting(*static_cast<Wrapped*>(src.pobj_), std::move(up)); set_starting(*static_cast<Wrapped*>(src.pobj_), std::move(up));
} }
}; };
static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting}; static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting};
...@@ -81,18 +82,16 @@ class any_flow_receiver { ...@@ -81,18 +82,16 @@ class any_flow_receiver {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static void done(data& src) { static void done(data& src) {
::pushmi::set_done(*static_cast<Wrapped*>((void*)src.buffer_)); set_done(*static_cast<Wrapped*>((void*)src.buffer_));
} }
static void error(data& src, E e) noexcept {::pushmi::set_error( static void error(data& src, E e) noexcept {
*static_cast<Wrapped*>((void*)src.buffer_), set_error(*static_cast<Wrapped*>((void*)src.buffer_), std::move(e));
std::move(e));
} }
static void value(data& src, VN... vn) { static void value(data& src, VN... vn) {
::pushmi::set_value( set_value(*static_cast<Wrapped*>((void*)src.buffer_), std::move(vn)...);
*static_cast<Wrapped*>((void*)src.buffer_), std::move(vn)...);
} }
static void starting(data& src, any_receiver<PE, PV> up) { static void starting(data& src, any_receiver<PE, PV> up) {
::pushmi::set_starting(*static_cast<Wrapped*>((void*)src.buffer_), std::move(up)); set_starting(*static_cast<Wrapped*>((void*)src.buffer_), std::move(up));
} }
}; };
static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting}; static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting};
...@@ -571,3 +570,4 @@ struct construct_deduced<flow_receiver> : make_flow_receiver_fn {}; ...@@ -571,3 +570,4 @@ struct construct_deduced<flow_receiver> : make_flow_receiver_fn {};
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/flow_receiver.h> #include <folly/experimental/pushmi/flow_receiver.h>
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class PE, class E, class... VN> template <class PE, class E, class... VN>
...@@ -54,12 +55,13 @@ class any_flow_single_sender { ...@@ -54,12 +55,13 @@ class any_flow_single_sender {
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{
::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))}; ::folly::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))};
} }
static void submit( static void submit(
data& src, data& src,
any_flow_receiver<PE, std::ptrdiff_t, E, VN...> out) { any_flow_receiver<PE, std::ptrdiff_t, E, VN...> out) {
::pushmi::submit(*static_cast<Wrapped*>(src.pobj_), std::move(out)); ::folly::pushmi::submit(
*static_cast<Wrapped*>(src.pobj_), std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::executor, s::submit}; static const vtable vtbl{s::op, s::executor, s::submit};
...@@ -77,13 +79,13 @@ class any_flow_single_sender { ...@@ -77,13 +79,13 @@ class any_flow_single_sender {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{::folly::pushmi::executor(
::pushmi::executor(*static_cast<Wrapped*>((void*)src.buffer_))}; *static_cast<Wrapped*>((void*)src.buffer_))};
} }
static void submit( static void submit(
data& src, data& src,
any_flow_receiver<PE, std::ptrdiff_t, E, VN...> out) { any_flow_receiver<PE, std::ptrdiff_t, E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>((void*)src.buffer_), std::move(out)); *static_cast<Wrapped*>((void*)src.buffer_), std::move(out));
} }
}; };
...@@ -256,3 +258,4 @@ struct construct_deduced<flow_single_sender> ...@@ -256,3 +258,4 @@ struct construct_deduced<flow_single_sender>
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/traits.h> #include <folly/experimental/pushmi/traits.h>
#include <chrono> #include <chrono>
#include <exception> #include <exception>
namespace folly {
namespace pushmi { namespace pushmi {
// property_set // property_set
...@@ -156,10 +157,10 @@ struct any_time_executor_ref; ...@@ -156,10 +157,10 @@ struct any_time_executor_ref;
namespace operators {} namespace operators {}
namespace extension_operators {} namespace extension_operators {}
namespace aliases { namespace aliases {
namespace v = ::pushmi; namespace v = ::folly::pushmi;
namespace mi = ::pushmi; namespace mi = ::folly::pushmi;
namespace op = ::pushmi::operators; namespace op = ::folly::pushmi::operators;
namespace ep = ::pushmi::extension_operators; namespace ep = ::folly::pushmi::extension_operators;
} // namespace aliases } // namespace aliases
namespace detail { namespace detail {
...@@ -170,3 +171,4 @@ struct any { ...@@ -170,3 +171,4 @@ struct any {
} // namespace detail } // namespace detail
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
namespace folly {
namespace pushmi { namespace pushmi {
class inline_constrained_executor_t { class inline_constrained_executor_t {
...@@ -36,8 +37,8 @@ class inline_constrained_executor_t { ...@@ -36,8 +37,8 @@ class inline_constrained_executor_t {
} }
PUSHMI_TEMPLATE(class CV, class Out) PUSHMI_TEMPLATE(class CV, class Out)
(requires Regular<CV>&& Receiver<Out>)void submit(CV, Out out) { (requires Regular<CV>&& Receiver<Out>)void submit(CV, Out out) {
::pushmi::set_value(out, *this); set_value(out, *this);
::pushmi::set_done(out); set_done(out);
} }
}; };
...@@ -69,8 +70,8 @@ class inline_time_executor_t { ...@@ -69,8 +70,8 @@ class inline_time_executor_t {
PUSHMI_TEMPLATE(class TP, class Out) PUSHMI_TEMPLATE(class TP, class Out)
(requires Regular<TP>&& Receiver<Out>)void submit(TP tp, Out out) { (requires Regular<TP>&& Receiver<Out>)void submit(TP tp, Out out) {
std::this_thread::sleep_until(tp); std::this_thread::sleep_until(tp);
::pushmi::set_value(out, *this); set_value(out, *this);
::pushmi::set_done(out); set_done(out);
} }
}; };
...@@ -98,8 +99,8 @@ class inline_executor_t { ...@@ -98,8 +99,8 @@ class inline_executor_t {
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>)void submit(Out out) { (requires Receiver<Out>)void submit(Out out) {
::pushmi::set_value(out, *this); set_value(out, *this);
::pushmi::set_done(out); set_done(out);
} }
}; };
...@@ -114,3 +115,4 @@ inline inline_executor_t inline_executor() { ...@@ -114,3 +115,4 @@ inline inline_executor_t inline_executor() {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class... VN> template <class E, class... VN>
...@@ -54,10 +55,11 @@ class any_many_sender { ...@@ -54,10 +55,11 @@ class any_many_sender {
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{
::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))}; ::folly::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))};
} }
static void submit(data& src, any_receiver<E, VN...> out) { static void submit(data& src, any_receiver<E, VN...> out) {
::pushmi::submit(*static_cast<Wrapped*>(src.pobj_), std::move(out)); ::folly::pushmi::submit(
*static_cast<Wrapped*>(src.pobj_), std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::executor, s::submit}; static const vtable vtbl{s::op, s::executor, s::submit};
...@@ -74,11 +76,11 @@ class any_many_sender { ...@@ -74,11 +76,11 @@ class any_many_sender {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{::folly::pushmi::executor(
::pushmi::executor(*static_cast<Wrapped*>((void*)src.buffer_))}; *static_cast<Wrapped*>((void*)src.buffer_))};
} }
static void submit(data& src, any_receiver<E, VN...> out) { static void submit(data& src, any_receiver<E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>((void*)src.buffer_), std::move(out)); *static_cast<Wrapped*>((void*)src.buffer_), std::move(out));
} }
}; };
...@@ -250,3 +252,4 @@ template<> ...@@ -250,3 +252,4 @@ template<>
struct construct_deduced<many_sender> : make_many_sender_fn {}; struct construct_deduced<many_sender> : make_many_sender_fn {};
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
// very poor perf example executor. // very poor perf example executor.
...@@ -38,8 +39,8 @@ struct new_thread_executor { ...@@ -38,8 +39,8 @@ struct new_thread_executor {
(requires Receiver<Out>) (requires Receiver<Out>)
void submit(Out out) { void submit(Out out) {
std::thread t{[out = std::move(out)]() mutable { std::thread t{[out = std::move(out)]() mutable {
auto tr = ::pushmi::trampoline(); auto tr = ::folly::pushmi::trampoline();
::pushmi::submit(tr, std::move(out)); ::folly::pushmi::submit(tr, std::move(out));
}}; }};
// pass ownership of thread to out // pass ownership of thread to out
t.detach(); t.detach();
...@@ -51,3 +52,4 @@ inline new_thread_executor new_thread() { ...@@ -51,3 +52,4 @@ inline new_thread_executor new_thread() {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace operators { namespace operators {
...@@ -33,7 +34,7 @@ PUSHMI_INLINE_VAR constexpr struct defer_fn { ...@@ -33,7 +34,7 @@ PUSHMI_INLINE_VAR constexpr struct defer_fn {
(requires Receiver<Out>) (requires Receiver<Out>)
void operator()(Data&, Out out) { void operator()(Data&, Out out) {
auto sender = f_(); auto sender = f_();
::pushmi::submit(sender, std::move(out)); submit(sender, std::move(out));
} }
}; };
...@@ -51,3 +52,4 @@ PUSHMI_INLINE_VAR constexpr struct defer_fn { ...@@ -51,3 +52,4 @@ PUSHMI_INLINE_VAR constexpr struct defer_fn {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/detail/functional.h> #include <folly/experimental/pushmi/detail/functional.h>
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
struct single_empty_sender_base : single_sender<ignoreSF, inlineEXF> { struct single_empty_sender_base : single_sender<ignoreSF, inlineEXF> {
...@@ -35,7 +36,7 @@ struct single_empty_impl { ...@@ -35,7 +36,7 @@ struct single_empty_impl {
void operator()( void operator()(
single_empty_sender_base&, single_empty_sender_base&,
Out out) { Out out) {
::pushmi::set_done(out); set_done(out);
} }
}; };
} // namespace detail } // namespace detail
...@@ -54,3 +55,4 @@ inline auto empty() { ...@@ -54,3 +55,4 @@ inline auto empty() {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
struct single_error_sender_base : single_sender<ignoreSF, inlineEXF> { struct single_error_sender_base : single_sender<ignoreSF, inlineEXF> {
...@@ -35,7 +36,7 @@ struct single_error_impl { ...@@ -35,7 +36,7 @@ struct single_error_impl {
void operator()( void operator()(
single_error_sender_base&, single_error_sender_base&,
Out out) { Out out) {
::pushmi::set_error(out, std::move(e_)); set_error(out, std::move(e_));
} }
}; };
} // namespace detail } // namespace detail
...@@ -52,3 +53,4 @@ auto error(E e) { ...@@ -52,3 +53,4 @@ auto error(E e) {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,20 +13,27 @@ ...@@ -14,20 +13,27 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/boosters.h> #include <folly/experimental/pushmi/boosters.h>
#include <folly/experimental/pushmi/concepts.h>
#include <folly/experimental/pushmi/detail/functional.h> #include <folly/experimental/pushmi/detail/functional.h>
#include <folly/experimental/pushmi/detail/if_constexpr.h> #include <folly/experimental/pushmi/detail/if_constexpr.h>
#include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/flow_many_sender.h> #include <folly/experimental/pushmi/flow_many_sender.h>
#include <folly/experimental/pushmi/flow_receiver.h> #include <folly/experimental/pushmi/flow_receiver.h>
#include <folly/experimental/pushmi/flow_single_sender.h> #include <folly/experimental/pushmi/flow_single_sender.h>
#include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/many_sender.h> #include <folly/experimental/pushmi/many_sender.h>
#include <folly/experimental/pushmi/piping.h> #include <folly/experimental/pushmi/piping.h>
#include <folly/experimental/pushmi/properties.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
#include <folly/experimental/pushmi/time_single_sender.h> #include <folly/experimental/pushmi/time_single_sender.h>
#include <folly/experimental/pushmi/traits.h>
#include <tuple> #include <tuple>
namespace folly {
namespace pushmi { namespace pushmi {
#if __cpp_lib_apply >= 201603 #if __cpp_lib_apply >= 201603
...@@ -35,14 +41,12 @@ using std::apply; ...@@ -35,14 +41,12 @@ using std::apply;
#else #else
namespace detail { namespace detail {
PUSHMI_TEMPLATE(class F, class Tuple, std::size_t... Is) PUSHMI_TEMPLATE(class F, class Tuple, std::size_t... Is)
(requires requires(pushmi::invoke( (requires requires(::folly::pushmi::invoke(
std::declval<F>(), std::declval<F>(),
std::get<Is>(std::declval<Tuple>())...))) std::get<Is>(std::declval<Tuple>())...)))
constexpr decltype(auto) apply_impl( constexpr decltype(auto) apply_impl(
F&& f, F&& f, Tuple&& t, std::index_sequence<Is...>) {
Tuple&& t, return ::folly::pushmi::invoke((F &&) f, std::get<Is>((Tuple &&) t)...);
std::index_sequence<Is...>) {
return pushmi::invoke((F &&) f, std::get<Is>((Tuple &&) t)...);
} }
template <class Tuple_, class Tuple = std::remove_reference_t<Tuple_>> template <class Tuple_, class Tuple = std::remove_reference_t<Tuple_>>
using tupidxs = std::make_index_sequence<std::tuple_size<Tuple>::value>; using tupidxs = std::make_index_sequence<std::tuple_size<Tuple>::value>;
...@@ -75,12 +79,12 @@ template <class Cardinality, bool IsFlow> ...@@ -75,12 +79,12 @@ template <class Cardinality, bool IsFlow>
struct receiver_from_impl { struct receiver_from_impl {
using MakeReceiver = make_receiver<Cardinality, IsFlow>; using MakeReceiver = make_receiver<Cardinality, IsFlow>;
template <class... AN> template <class... AN>
using receiver_type = pushmi::invoke_result_t<MakeReceiver&, AN...>; using receiver_type = ::folly::pushmi::invoke_result_t<MakeReceiver&, AN...>;
PUSHMI_TEMPLATE(class... Ts) PUSHMI_TEMPLATE(class... Ts)
(requires Invocable<MakeReceiver, Ts...>) (requires Invocable<MakeReceiver, Ts...>)
auto operator()( auto operator()(
std::tuple<Ts...> args) const { std::tuple<Ts...> args) const {
return pushmi::apply(MakeReceiver(), std::move(args)); return ::folly::pushmi::apply(MakeReceiver(), std::move(args));
} }
PUSHMI_TEMPLATE( PUSHMI_TEMPLATE(
class... Ts, class... Ts,
...@@ -89,7 +93,7 @@ struct receiver_from_impl { ...@@ -89,7 +93,7 @@ struct receiver_from_impl {
(requires And<SemiMovable<Fns>...>&& Invocable<MakeReceiver, Ts...>&& (requires And<SemiMovable<Fns>...>&& Invocable<MakeReceiver, Ts...>&&
Invocable< Invocable<
This, This,
pushmi::invoke_result_t<MakeReceiver, Ts...>, ::folly::pushmi::invoke_result_t<MakeReceiver, Ts...>,
Fns...>) Fns...>)
auto operator()(std::tuple<Ts...> args, Fns... fns) const { auto operator()(std::tuple<Ts...> args, Fns... fns) const {
return This()(This()(std::move(args)), std::move(fns)...); return This()(This()(std::move(args)), std::move(fns)...);
...@@ -117,9 +121,9 @@ struct submit_transform_out_1 { ...@@ -117,9 +121,9 @@ struct submit_transform_out_1 {
FN fn_; FN fn_;
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>&& Invocable<FN, Out>&& (requires Receiver<Out>&& Invocable<FN, Out>&&
SenderTo<In, pushmi::invoke_result_t<const FN&, Out>>) SenderTo<In, ::folly::pushmi::invoke_result_t<const FN&, Out>>)
void operator()(In& in, Out out) const { void operator()(In& in, Out out) const {
::pushmi::submit(in, fn_(std::move(out))); submit(in, fn_(std::move(out)));
} }
}; };
template <class In, class FN> template <class In, class FN>
...@@ -127,9 +131,9 @@ struct submit_transform_out_2 { ...@@ -127,9 +131,9 @@ struct submit_transform_out_2 {
FN fn_; FN fn_;
PUSHMI_TEMPLATE(class CV, class Out) PUSHMI_TEMPLATE(class CV, class Out)
(requires Receiver<Out>&& Invocable<FN, Out>&& (requires Receiver<Out>&& Invocable<FN, Out>&&
ConstrainedSenderTo<In, pushmi::invoke_result_t<const FN&, Out>>) ConstrainedSenderTo<In, ::folly::pushmi::invoke_result_t<const FN&, Out>>)
void operator()(In& in, CV cv, Out out) const { void operator()(In& in, CV cv, Out out) const {
::pushmi::submit(in, cv, fn_(std::move(out))); submit(in, cv, fn_(std::move(out)));
} }
}; };
template <class In, class SDSF> template <class In, class SDSF>
...@@ -247,8 +251,8 @@ struct set_value_fn { ...@@ -247,8 +251,8 @@ struct set_value_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue<Out, VN...>) (requires ReceiveValue<Out, VN...>)
void operator()(Out out) { void operator()(Out out) {
::pushmi::apply( ::folly::pushmi::apply(
::pushmi::set_value, ::folly::pushmi::set_value,
std::tuple_cat(std::tuple<Out>{std::move(out)}, std::move(vn_))); std::tuple_cat(std::tuple<Out>{std::move(out)}, std::move(vn_)));
} }
}; };
...@@ -268,7 +272,7 @@ struct set_error_fn { ...@@ -268,7 +272,7 @@ struct set_error_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveError<Out, E>) (requires ReceiveError<Out, E>)
void operator()(Out out) { void operator()(Out out) {
::pushmi::set_error(out, std::move(e_)); set_error(out, std::move(e_));
} }
}; };
...@@ -286,7 +290,7 @@ struct set_done_fn { ...@@ -286,7 +290,7 @@ struct set_done_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>)
void operator()(Out out) { void operator()(Out out) {
::pushmi::set_done(out); set_done(out);
} }
}; };
...@@ -304,7 +308,7 @@ struct set_starting_fn { ...@@ -304,7 +308,7 @@ struct set_starting_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>)
void operator()(Out out) { void operator()(Out out) {
::pushmi::set_starting(out, std::move(up_)); set_starting(out, std::move(up_));
} }
}; };
...@@ -322,7 +326,7 @@ struct executor_fn { ...@@ -322,7 +326,7 @@ struct executor_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In& in) const { auto operator()(In& in) const {
return ::pushmi::executor(in); return executor(in);
} }
}; };
...@@ -340,7 +344,7 @@ struct do_submit_fn { ...@@ -340,7 +344,7 @@ struct do_submit_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires SenderTo<In, Out>) (requires SenderTo<In, Out>)
void operator()(In& in) { void operator()(In& in) {
::pushmi::submit(in, std::move(out_)); submit(in, std::move(out_));
} }
}; };
template <class TP, class Out> template <class TP, class Out>
...@@ -350,7 +354,7 @@ struct do_submit_fn { ...@@ -350,7 +354,7 @@ struct do_submit_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires TimeSenderTo<In, Out>) (requires TimeSenderTo<In, Out>)
void operator()(In& in) { void operator()(In& in) {
::pushmi::submit(in, std::move(tp_), std::move(out_)); submit(in, std::move(tp_), std::move(out_));
} }
}; };
...@@ -373,7 +377,7 @@ struct top_fn { ...@@ -373,7 +377,7 @@ struct top_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires ConstrainedSender<In>) (requires ConstrainedSender<In>)
auto operator()(In& in) const { auto operator()(In& in) const {
return ::pushmi::top(in); return ::folly::pushmi::top(in);
} }
}; };
...@@ -389,7 +393,7 @@ struct now_fn { ...@@ -389,7 +393,7 @@ struct now_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires TimeSender<In>) (requires TimeSender<In>)
auto operator()(In& in) const { auto operator()(In& in) const {
return ::pushmi::now(in); return ::folly::pushmi::now(in);
} }
}; };
...@@ -415,3 +419,4 @@ PUSHMI_INLINE_VAR constexpr detail::top_fn top{}; ...@@ -415,3 +419,4 @@ PUSHMI_INLINE_VAR constexpr detail::top_fn top{};
} // namespace extension_operators } // namespace extension_operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/piping.h> #include <folly/experimental/pushmi/piping.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -31,7 +32,7 @@ struct filter_fn { ...@@ -31,7 +32,7 @@ struct filter_fn {
(requires Receiver<Out>) (requires Receiver<Out>)
void operator()(Out& out, VN&&... vn) const { void operator()(Out& out, VN&&... vn) const {
if (p_(as_const(vn)...)) { if (p_(as_const(vn)...)) {
::pushmi::set_value(out, (VN &&) vn...); set_value(out, (VN &&) vn...);
} }
} }
}; };
...@@ -41,7 +42,7 @@ struct filter_fn { ...@@ -41,7 +42,7 @@ struct filter_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>)
auto operator()(Out out) const { auto operator()(Out out) const {
return ::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
std::move(out), std::move(out),
// copy 'p' to allow multiple calls to submit // copy 'p' to allow multiple calls to submit
on_value_impl<In, Predicate>{p_}); on_value_impl<In, Predicate>{p_});
...@@ -53,9 +54,9 @@ struct filter_fn { ...@@ -53,9 +54,9 @@ struct filter_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::folly::pushmi::detail::submit_transform_out<In>(
submit_impl<In, Predicate>{p_})); submit_impl<In, Predicate>{p_}));
} }
}; };
...@@ -75,3 +76,4 @@ PUSHMI_INLINE_VAR constexpr detail::filter_fn filter{}; ...@@ -75,3 +76,4 @@ PUSHMI_INLINE_VAR constexpr detail::filter_fn filter{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -35,14 +36,14 @@ struct for_each_fn { ...@@ -35,14 +36,14 @@ struct for_each_fn {
std::function<void(std::ptrdiff_t)> pull; std::function<void(std::ptrdiff_t)> pull;
template <class V> template <class V>
void value(V&& v) { void value(V&& v) {
::pushmi::set_value(static_cast<Out&>(*this), (V &&) v); set_value(static_cast<Out&>(*this), (V &&) v);
pull(1); pull(1);
} }
PUSHMI_TEMPLATE(class Up) PUSHMI_TEMPLATE(class Up)
(requires Receiver<Up>) (requires Receiver<Up>)
void starting(Up up) { void starting(Up up) {
pull = [up = std::move(up)](std::ptrdiff_t requested) mutable { pull = [up = std::move(up)](std::ptrdiff_t requested) mutable {
::pushmi::set_value(up, requested); set_value(up, requested);
}; };
pull(1); pull(1);
} }
...@@ -56,29 +57,29 @@ struct for_each_fn { ...@@ -56,29 +57,29 @@ struct for_each_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>&& Flow<In>&& Many<In>) (requires Sender<In>&& Flow<In>&& Many<In>)
In operator()(In in) { In operator()(In in) {
auto out{::pushmi::detail::receiver_from_fn<subset< auto out{::folly::pushmi::detail::receiver_from_fn<subset<
is_sender<>, is_sender<>,
property_set_index_t<properties_t<In>, is_single<>>>>()( property_set_index_t<properties_t<In>, is_single<>>>>()(
std::move(args_))}; std::move(args_))};
using Out = decltype(out); using Out = decltype(out);
::pushmi::submit( submit(
in, in,
::pushmi::detail::receiver_from_fn<In>()( ::folly::pushmi::detail::receiver_from_fn<In>()(
Pull<In, Out>{std::move(out)})); Pull<In, Out>{std::move(out)}));
return in; return in;
} }
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>&& Constrained<In>&& Flow<In>&& Many<In>) (requires Sender<In>&& Constrained<In>&& Flow<In>&& Many<In>)
In operator()(In in) { In operator()(In in) {
auto out{::pushmi::detail::receiver_from_fn<subset< auto out{::folly::pushmi::detail::receiver_from_fn<subset<
is_sender<>, is_sender<>,
property_set_index_t<properties_t<In>, is_single<>>>>()( property_set_index_t<properties_t<In>, is_single<>>>>()(
std::move(args_))}; std::move(args_))};
using Out = decltype(out); using Out = decltype(out);
::pushmi::submit( submit(
in, in,
::pushmi::top(in), ::folly::pushmi::top(in),
::pushmi::detail::receiver_from_fn<In>()( ::folly::pushmi::detail::receiver_from_fn<In>()(
Pull<In, Out>{std::move(out)})); Pull<In, Out>{std::move(out)}));
return in; return in;
} }
...@@ -98,3 +99,4 @@ PUSHMI_INLINE_VAR constexpr detail::for_each_fn for_each{}; ...@@ -98,3 +99,4 @@ PUSHMI_INLINE_VAR constexpr detail::for_each_fn for_each{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/flow_many_sender.h> #include <folly/experimental/pushmi/flow_many_sender.h>
#include <folly/experimental/pushmi/many_sender.h> #include <folly/experimental/pushmi/many_sender.h>
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
...@@ -52,9 +53,9 @@ PUSHMI_INLINE_VAR constexpr struct from_fn { ...@@ -52,9 +53,9 @@ PUSHMI_INLINE_VAR constexpr struct from_fn {
void operator()(sender_base&, Out out) const { void operator()(sender_base&, Out out) const {
auto c = begin_; auto c = begin_;
for (; c != end_; ++c) { for (; c != end_; ++c) {
::pushmi::set_value(out, *c); set_value(out, *c);
} }
::pushmi::set_done(out); set_done(out);
} }
}; };
...@@ -101,35 +102,32 @@ struct flow_from_up { ...@@ -101,35 +102,32 @@ struct flow_from_up {
return; return;
} }
// submit work to exec // submit work to exec
::pushmi::submit(p->exec, make_receiver([p = p, requested](auto) { submit(p->exec, make_receiver([p = p, requested](auto) {
auto remaining = requested; auto remaining = requested;
// this loop is structured to work when there is // this loop is structured to work when there is
// re-entrancy out.value in the loop may call up.value. // re-entrancy out.value in the loop may call up.value.
// to handle this the state of p->c must be captured and // to handle this the state of p->c must be captured and
// the remaining and p->c must be changed before // the remaining and p->c must be changed before
// out.value is called. // out.value is called.
while (remaining-- > 0 && !p->stop && p->c != p->end) { while (remaining-- > 0 && !p->stop && p->c != p->end) {
auto i = (p->c)++; auto i = (p->c)++;
::pushmi::set_value( set_value(p->out, ::folly::pushmi::detail::as_const(*i));
p->out, ::pushmi::detail::as_const(*i)); }
} if (p->c == p->end) {
if (p->c == p->end) { set_done(p->out);
::pushmi::set_done(p->out); }
} }));
}));
} }
template <class E> template <class E>
void error(E) noexcept { void error(E) noexcept {
p->stop.store(true); p->stop.store(true);
::pushmi::submit( submit(p->exec, make_receiver([p = p](auto) { set_done(p->out); }));
p->exec, make_receiver([p = p](auto) { ::pushmi::set_done(p->out); }));
} }
void done() { void done() {
p->stop.store(true); p->stop.store(true);
::pushmi::submit( submit(p->exec, make_receiver([p = p](auto) { set_done(p->out); }));
p->exec, make_receiver([p = p](auto) { ::pushmi::set_done(p->out); }));
} }
}; };
...@@ -149,11 +147,10 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn { ...@@ -149,11 +147,10 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn {
auto p = std::make_shared<Producer>( auto p = std::make_shared<Producer>(
begin_, end_, std::move(out), exec_, false); begin_, end_, std::move(out), exec_, false);
::pushmi::submit(exec_, make_receiver([p](auto) { submit(exec_, make_receiver([p](auto) {
// pass reference for cancellation. // pass reference for cancellation.
::pushmi::set_starting( set_starting(p->out, make_receiver(flow_from_up<Producer>{p}));
p->out, make_receiver(flow_from_up<Producer>{p})); }));
}));
} }
}; };
...@@ -192,3 +189,4 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn { ...@@ -192,3 +189,4 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace operators { namespace operators {
...@@ -38,10 +39,10 @@ PUSHMI_INLINE_VAR constexpr struct just_fn { ...@@ -38,10 +39,10 @@ PUSHMI_INLINE_VAR constexpr struct just_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue<Out, VN...>) (requires ReceiveValue<Out, VN...>)
void operator()(sender_base&, Out out) { void operator()(sender_base&, Out out) {
::pushmi::apply( ::folly::pushmi::apply(
::pushmi::set_value, ::folly::pushmi::set_value,
std::tuple_cat(std::tuple<Out&>{out}, std::move(vn_))); std::tuple_cat(std::tuple<Out&>{out}, std::move(vn_)));
::pushmi::set_done(std::move(out)); set_done(std::move(out));
} }
}; };
...@@ -56,3 +57,4 @@ PUSHMI_INLINE_VAR constexpr struct just_fn { ...@@ -56,3 +57,4 @@ PUSHMI_INLINE_VAR constexpr struct just_fn {
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/piping.h> #include <folly/experimental/pushmi/piping.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -30,7 +31,7 @@ struct on_fn { ...@@ -30,7 +31,7 @@ struct on_fn {
In in_; In in_;
Out out_; Out out_;
void operator()(any) { void operator()(any) {
::pushmi::submit(in_, std::move(out_)); submit(in_, std::move(out_));
} }
}; };
template <class In, class ExecutorFactory> template <class In, class ExecutorFactory>
...@@ -40,9 +41,10 @@ struct on_fn { ...@@ -40,9 +41,10 @@ struct on_fn {
(requires SenderTo<In, Out>) (requires SenderTo<In, Out>)
void operator()(In& in, Out out) const { void operator()(In& in, Out out) const {
auto exec = ef_(); auto exec = ef_();
::pushmi::submit( submit(
exec, exec,
::pushmi::make_receiver(on_value_impl<In, Out>{in, std::move(out)})); ::folly::pushmi::make_receiver(
on_value_impl<In, Out>{in, std::move(out)}));
} }
}; };
template <class In, class TP, class Out> template <class In, class TP, class Out>
...@@ -51,7 +53,7 @@ struct on_fn { ...@@ -51,7 +53,7 @@ struct on_fn {
TP at_; TP at_;
Out out_; Out out_;
void operator()(any) { void operator()(any) {
::pushmi::submit(in_, at_, std::move(out_)); submit(in_, at_, std::move(out_));
} }
}; };
template <class In, class ExecutorFactory> template <class In, class ExecutorFactory>
...@@ -61,10 +63,10 @@ struct on_fn { ...@@ -61,10 +63,10 @@ struct on_fn {
(requires TimeSenderTo<In, Out>) (requires TimeSenderTo<In, Out>)
void operator()(In& in, TP at, Out out) const { void operator()(In& in, TP at, Out out) const {
auto exec = ef_(); auto exec = ef_();
::pushmi::submit( submit(
exec, exec,
at, at,
::pushmi::make_receiver( ::folly::pushmi::make_receiver(
time_on_value_impl<In, TP, Out>{in, at, std::move(out)})); time_on_value_impl<In, TP, Out>{in, at, std::move(out)}));
} }
}; };
...@@ -74,7 +76,7 @@ struct on_fn { ...@@ -74,7 +76,7 @@ struct on_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
detail::submit_transform_out<In>( detail::submit_transform_out<In>(
out_impl<In, ExecutorFactory>{ef_}, out_impl<In, ExecutorFactory>{ef_},
...@@ -100,3 +102,4 @@ PUSHMI_INLINE_VAR constexpr detail::on_fn on{}; ...@@ -100,3 +102,4 @@ PUSHMI_INLINE_VAR constexpr detail::on_fn on{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,23 +13,26 @@ ...@@ -14,23 +13,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/o/via.h> #include <folly/experimental/pushmi/o/via.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <typename In> template <typename In>
struct send_via { struct send_via {
In in; In in;
PUSHMI_TEMPLATE(class... AN) PUSHMI_TEMPLATE(class... AN)
(requires Invocable<decltype(::pushmi::operators::via), AN...>&& Invocable< (requires Invocable<decltype(::folly::pushmi::operators::via), AN...>&&
invoke_result_t<decltype(::pushmi::operators::via), AN...>, Invocable<
In>) invoke_result_t<decltype(::folly::pushmi::operators::via), AN...>,
In>)
auto via(AN&&... an) { auto via(AN&&... an) {
return in | ::pushmi::operators::via((AN &&) an...); return in | ::folly::pushmi::operators::via((AN &&) an...);
} }
}; };
...@@ -73,3 +75,4 @@ auto via_cast(send_via<In> ss) { ...@@ -73,3 +75,4 @@ auto via_cast(send_via<In> ss) {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <folly/experimental/pushmi/subject.h> #include <folly/experimental/pushmi/subject.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -33,7 +34,7 @@ struct share_fn { ...@@ -33,7 +34,7 @@ struct share_fn {
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
subject<properties_t<In>, TN...> sub; subject<properties_t<In>, TN...> sub;
::pushmi::submit(in, sub.receiver()); submit(in, sub.receiver());
return sub; return sub;
} }
}; };
...@@ -54,3 +55,4 @@ PUSHMI_INLINE_VAR constexpr detail::share_fn<TN...> share{}; ...@@ -54,3 +55,4 @@ PUSHMI_INLINE_VAR constexpr detail::share_fn<TN...> share{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/boosters.h> #include <folly/experimental/pushmi/boosters.h>
#include <folly/experimental/pushmi/detail/if_constexpr.h> #include <folly/experimental/pushmi/detail/if_constexpr.h>
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
#include <functional> #include <functional>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
namespace submit_detail { namespace submit_detail {
...@@ -55,8 +56,9 @@ struct submit_fn { ...@@ -55,8 +56,9 @@ struct submit_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires submit_detail::AutoSenderTo<In, AN...>) (requires submit_detail::AutoSenderTo<In, AN...>)
In operator()(In in) { In operator()(In in) {
auto out{::pushmi::detail::receiver_from_fn<In>{}(std::move(args_))}; auto out{
::pushmi::submit(in, std::move(out)); ::folly::pushmi::detail::receiver_from_fn<In>{}(std::move(args_))};
submit(in, std::move(out));
return in; return in;
} }
}; };
...@@ -77,8 +79,9 @@ struct submit_at_fn { ...@@ -77,8 +79,9 @@ struct submit_at_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires submit_detail::AutoTimeSenderTo<In, AN...>) (requires submit_detail::AutoTimeSenderTo<In, AN...>)
In operator()(In in) { In operator()(In in) {
auto out{::pushmi::detail::receiver_from_fn<In>()(std::move(args_))}; auto out{
::pushmi::submit(in, std::move(at_), std::move(out)); ::folly::pushmi::detail::receiver_from_fn<In>()(std::move(args_))};
submit(in, std::move(at_), std::move(out));
return in; return in;
} }
}; };
...@@ -103,9 +106,10 @@ struct submit_after_fn { ...@@ -103,9 +106,10 @@ struct submit_after_fn {
// TODO - only move, move-only types.. // TODO - only move, move-only types..
// if out can be copied, then submit can be called multiple // if out can be copied, then submit can be called multiple
// times.. // times..
auto out{::pushmi::detail::receiver_from_fn<In>()(std::move(args_))}; auto out{
auto at = ::pushmi::now(in) + std::move(after_); ::folly::pushmi::detail::receiver_from_fn<In>()(std::move(args_))};
::pushmi::submit(in, std::move(at), std::move(out)); auto at = ::folly::pushmi::now(in) + std::move(after_);
submit(in, std::move(at), std::move(out));
return in; return in;
} }
}; };
...@@ -155,28 +159,27 @@ struct blocking_submit_fn { ...@@ -155,28 +159,27 @@ struct blocking_submit_fn {
using properties = properties_t<Exec>; using properties = properties_t<Exec>;
auto executor() { auto executor() {
return make(state_, ::pushmi::executor(ex_)); return make(state_, executor(ex_));
} }
PUSHMI_TEMPLATE(class... ZN) PUSHMI_TEMPLATE(class... ZN)
(requires Constrained<Exec>) (requires Constrained<Exec>)
auto top() { auto top() {
return ::pushmi::top(ex_); return ::folly::pushmi::top(ex_);
} }
PUSHMI_TEMPLATE(class CV, class Out) PUSHMI_TEMPLATE(class CV, class Out)
(requires Receiver<Out>&& Constrained<Exec>) (requires Receiver<Out>&& Constrained<Exec>)
void submit(CV cv, Out out) { void submit(CV cv, Out out) {
++state_->nested; ++state_->nested;
::pushmi::submit( submit(ex_, cv, nested_receiver_impl<Out>{state_, std::move(out)});
ex_, cv, nested_receiver_impl<Out>{state_, std::move(out)});
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out> && not Constrained<Exec>) (requires Receiver<Out> && not Constrained<Exec>)
void submit(Out out) { void submit(Out out) {
++state_->nested; ++state_->nested;
::pushmi::submit(ex_, nested_receiver_impl<Out>{state_, std::move(out)}); submit(ex_, nested_receiver_impl<Out>{state_, std::move(out)});
} }
}; };
template <class Out> template <class Out>
...@@ -193,11 +196,11 @@ struct blocking_submit_fn { ...@@ -193,11 +196,11 @@ struct blocking_submit_fn {
std::exception_ptr e; std::exception_ptr e;
using executor_t = remove_cvref_t<V>; using executor_t = remove_cvref_t<V>;
auto n = nested_executor_impl<executor_t>::make(state_, (V &&) v); auto n = nested_executor_impl<executor_t>::make(state_, (V &&) v);
::pushmi::set_value(out_, any_executor_ref<>{n}); set_value(out_, any_executor_ref<>{n});
} }
template <class E> template <class E>
void error(E&& e) noexcept { void error(E&& e) noexcept {
::pushmi::set_error(out_, (E &&) e); set_error(out_, (E &&) e);
if (--state_->nested == 0) { if (--state_->nested == 0) {
state_->signaled.notify_all(); state_->signaled.notify_all();
} }
...@@ -205,7 +208,7 @@ struct blocking_submit_fn { ...@@ -205,7 +208,7 @@ struct blocking_submit_fn {
void done() { void done() {
std::exception_ptr e; std::exception_ptr e;
try { try {
::pushmi::set_done(out_); set_done(out_);
} catch (...) { } catch (...) {
e = std::current_exception(); e = std::current_exception();
} }
...@@ -229,13 +232,13 @@ struct blocking_submit_fn { ...@@ -229,13 +232,13 @@ struct blocking_submit_fn {
PUSHMI_TEMPLATE(class Out, class Value) PUSHMI_TEMPLATE(class Out, class Value)
(requires Executor<std::decay_t<Value>>&& ReceiveValue< (requires Executor<std::decay_t<Value>>&& ReceiveValue<
Out, Out,
pushmi::invoke_result_t< ::folly::pushmi::invoke_result_t<
nested_executor_impl_fn, nested_executor_impl_fn,
lock_state*, lock_state*,
std::decay_t<Value>>>) std::decay_t<Value>>>)
void operator()(Out out, Value&& v) const { void operator()(Out out, Value&& v) const {
++state_->nested; ++state_->nested;
::pushmi::set_value(out, nested_executor_impl_fn{}(state_, (Value &&) v)); set_value(out, nested_executor_impl_fn{}(state_, (Value &&) v));
if (--state_->nested == 0) { if (--state_->nested == 0) {
std::unique_lock<std::mutex> guard{state_->lock}; std::unique_lock<std::mutex> guard{state_->lock};
state_->signaled.notify_all(); state_->signaled.notify_all();
...@@ -245,7 +248,7 @@ struct blocking_submit_fn { ...@@ -245,7 +248,7 @@ struct blocking_submit_fn {
(requires True<>&& ReceiveValue<Out, VN...> && (requires True<>&& ReceiveValue<Out, VN...> &&
not(sizeof...(VN) == 1 && And<Executor<std::decay_t<VN>>...>)) not(sizeof...(VN) == 1 && And<Executor<std::decay_t<VN>>...>))
void operator()(Out out, VN&&... vn) const { void operator()(Out out, VN&&... vn) const {
::pushmi::set_value(out, (VN &&) vn...); set_value(out, (VN &&) vn...);
} }
}; };
struct on_error_impl { struct on_error_impl {
...@@ -253,7 +256,7 @@ struct blocking_submit_fn { ...@@ -253,7 +256,7 @@ struct blocking_submit_fn {
PUSHMI_TEMPLATE(class Out, class E) PUSHMI_TEMPLATE(class Out, class E)
(requires ReceiveError<Out, E>) (requires ReceiveError<Out, E>)
void operator()(Out out, E e) const noexcept { void operator()(Out out, E e) const noexcept {
::pushmi::set_error(out, std::move(e)); set_error(out, std::move(e));
std::unique_lock<std::mutex> guard{state_->lock}; std::unique_lock<std::mutex> guard{state_->lock};
state_->done = true; state_->done = true;
state_->signaled.notify_all(); state_->signaled.notify_all();
...@@ -264,7 +267,7 @@ struct blocking_submit_fn { ...@@ -264,7 +267,7 @@ struct blocking_submit_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>)
void operator()(Out out) const { void operator()(Out out) const {
::pushmi::set_done(out); set_done(out);
std::unique_lock<std::mutex> guard{state_->lock}; std::unique_lock<std::mutex> guard{state_->lock};
state_->done = true; state_->done = true;
state_->signaled.notify_all(); state_->signaled.notify_all();
...@@ -278,7 +281,7 @@ struct blocking_submit_fn { ...@@ -278,7 +281,7 @@ struct blocking_submit_fn {
auto operator()( auto operator()(
lock_state* state, lock_state* state,
std::tuple<AN...> args) const { std::tuple<AN...> args) const {
return ::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
std::move(args), std::move(args),
on_value_impl{state}, on_value_impl{state},
on_error_impl{state}, on_error_impl{state},
...@@ -290,7 +293,7 @@ struct blocking_submit_fn { ...@@ -290,7 +293,7 @@ struct blocking_submit_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>&& SenderTo<In, Out>) (requires Receiver<Out>&& SenderTo<In, Out>)
void operator()(In& in, Out out) const { void operator()(In& in, Out out) const {
::pushmi::submit(in, std::move(out)); submit(in, std::move(out));
} }
}; };
// TODO - only move, move-only types.. // TODO - only move, move-only types..
...@@ -304,7 +307,7 @@ struct blocking_submit_fn { ...@@ -304,7 +307,7 @@ struct blocking_submit_fn {
(requires Sender<In>&& Invocable< (requires Sender<In>&& Invocable<
submit_impl<In>&, submit_impl<In>&,
In&, In&,
pushmi::invoke_result_t< ::folly::pushmi::invoke_result_t<
receiver_impl<In>, receiver_impl<In>,
lock_state*, lock_state*,
std::tuple<AN...>&&>> && std::tuple<AN...>&&>> &&
...@@ -334,14 +337,14 @@ template <class T> ...@@ -334,14 +337,14 @@ template <class T>
struct get_fn { struct get_fn {
private: private:
struct on_value_impl { struct on_value_impl {
pushmi::detail::opt<T>* result_; ::folly::pushmi::detail::opt<T>* result_;
template <class... TN> template <class... TN>
void operator()(TN&&... tn) const { void operator()(TN&&... tn) const {
*result_ = T{(TN &&) tn...}; *result_ = T{(TN &&) tn...};
} }
}; };
struct on_error_impl { struct on_error_impl {
pushmi::detail::opt<std::exception_ptr>* ep_; ::folly::pushmi::detail::opt<std::exception_ptr>* ep_;
template <class E> template <class E>
void operator()(E e) const noexcept { void operator()(E e) const noexcept {
*ep_ = std::make_exception_ptr(e); *ep_ = std::make_exception_ptr(e);
...@@ -356,10 +359,10 @@ struct get_fn { ...@@ -356,10 +359,10 @@ struct get_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
T operator()(In in) const { T operator()(In in) const {
pushmi::detail::opt<T> result_; ::folly::pushmi::detail::opt<T> result_;
pushmi::detail::opt<std::exception_ptr> ep_; ::folly::pushmi::detail::opt<std::exception_ptr> ep_;
auto out = auto out = ::folly::pushmi::make_receiver(
::pushmi::make_receiver(on_value_impl{&result_}, on_error_impl{&ep_}); on_value_impl{&result_}, on_error_impl{&ep_});
using Out = decltype(out); using Out = decltype(out);
static_assert( static_assert(
SenderTo<In, Out>, SenderTo<In, Out>,
...@@ -385,3 +388,4 @@ PUSHMI_INLINE_VAR constexpr detail::get_fn<T> get{}; ...@@ -385,3 +388,4 @@ PUSHMI_INLINE_VAR constexpr detail::get_fn<T> get{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/piping.h> #include <folly/experimental/pushmi/piping.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -29,13 +30,13 @@ struct switch_on_error_fn { ...@@ -29,13 +30,13 @@ struct switch_on_error_fn {
ErrorSelector es_; ErrorSelector es_;
PUSHMI_TEMPLATE(class Out, class E) PUSHMI_TEMPLATE(class Out, class E)
(requires Receiver<Out>&& Invocable<const ErrorSelector&, E>&& (requires Receiver<Out>&& Invocable<const ErrorSelector&, E>&&
SenderTo<pushmi::invoke_result_t<ErrorSelector&, E>, Out>) SenderTo<::folly::pushmi::invoke_result_t<ErrorSelector&, E>, Out>)
void operator()(Out& out, E&& e) const noexcept { void operator()(Out& out, E&& e) const noexcept {
static_assert( static_assert(
::pushmi::NothrowInvocable<const ErrorSelector&, E>, ::folly::pushmi::NothrowInvocable<const ErrorSelector&, E>,
"switch_on_error - error selector function must be noexcept"); "switch_on_error - error selector function must be noexcept");
auto next = es_((E &&) e); auto next = es_((E &&) e);
::pushmi::submit(next, out); submit(next, out);
} }
}; };
template <class In, class ErrorSelector> template <class In, class ErrorSelector>
...@@ -44,10 +45,10 @@ struct switch_on_error_fn { ...@@ -44,10 +45,10 @@ struct switch_on_error_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>)
auto operator()(Out out) const { auto operator()(Out out) const {
return ::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
std::move(out), std::move(out),
// copy 'es' to allow multiple calls to submit // copy 'es' to allow multiple calls to submit
::pushmi::on_error(on_error_impl<ErrorSelector>{es_})); ::folly::pushmi::on_error(on_error_impl<ErrorSelector>{es_}));
} }
}; };
template <class ErrorSelector> template <class ErrorSelector>
...@@ -56,9 +57,9 @@ struct switch_on_error_fn { ...@@ -56,9 +57,9 @@ struct switch_on_error_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::folly::pushmi::detail::submit_transform_out<In>(
out_impl<In, ErrorSelector>{es_})); out_impl<In, ErrorSelector>{es_}));
} }
}; };
...@@ -78,3 +79,4 @@ PUSHMI_INLINE_VAR constexpr detail::switch_on_error_fn switch_on_error{}; ...@@ -78,3 +79,4 @@ PUSHMI_INLINE_VAR constexpr detail::switch_on_error_fn switch_on_error{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,12 @@ ...@@ -14,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <cassert> #include <cassert>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -37,27 +38,27 @@ struct tap_ { ...@@ -37,27 +38,27 @@ struct tap_ {
Out, Out,
std::remove_reference_t<VN>...>) std::remove_reference_t<VN>...>)
void value(VN&&... vn) { void value(VN&&... vn) {
::pushmi::set_value(sideEffects, as_const(vn)...); set_value(sideEffects, as_const(vn)...);
::pushmi::set_value(out, (VN &&) vn...); set_value(out, (VN &&) vn...);
} }
PUSHMI_TEMPLATE(class E) PUSHMI_TEMPLATE(class E)
(requires ReceiveError<SideEffects, const E>&& (requires ReceiveError<SideEffects, const E>&&
ReceiveError<Out, E>) ReceiveError<Out, E>)
void error(E e) noexcept { void error(E e) noexcept {
::pushmi::set_error(sideEffects, as_const(e)); set_error(sideEffects, as_const(e));
::pushmi::set_error(out, std::move(e)); set_error(out, std::move(e));
} }
void done() { void done() {
::pushmi::set_done(sideEffects); set_done(sideEffects);
::pushmi::set_done(out); set_done(out);
} }
PUSHMI_TEMPLATE(class Up, class UUp = std::remove_reference_t<Up>) PUSHMI_TEMPLATE(class Up, class UUp = std::remove_reference_t<Up>)
(requires FlowReceiver<SideEffects>&& FlowReceiver<Out>) (requires FlowReceiver<SideEffects>&& FlowReceiver<Out>)
void starting( void starting(
Up&& up) { Up&& up) {
// up is not made const because sideEffects is allowed to call methods on up // up is not made const because sideEffects is allowed to call methods on up
::pushmi::set_starting(sideEffects, up); set_starting(sideEffects, up);
::pushmi::set_starting(out, (Up &&) up); set_starting(out, (Up &&) up);
} }
}; };
...@@ -77,9 +78,9 @@ struct tap_fn { ...@@ -77,9 +78,9 @@ struct tap_fn {
static auto impl( static auto impl(
In in, In in,
SideEffects sideEffects) { SideEffects sideEffects) {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::folly::pushmi::detail::submit_transform_out<In>(
out_impl<In, SideEffects>{std::move(sideEffects)})); out_impl<In, SideEffects>{std::move(sideEffects)}));
} }
...@@ -91,7 +92,7 @@ struct tap_fn { ...@@ -91,7 +92,7 @@ struct tap_fn {
auto operator()(In in) { auto operator()(In in) {
return tap_fn::impl( return tap_fn::impl(
std::move(in), std::move(in),
::pushmi::detail::receiver_from_fn<In>()(std::move(args_))); ::folly::pushmi::detail::receiver_from_fn<In>()(std::move(args_)));
} }
}; };
PUSHMI_TEMPLATE(class In, class SideEffects) PUSHMI_TEMPLATE(class In, class SideEffects)
...@@ -101,11 +102,12 @@ struct tap_fn { ...@@ -101,11 +102,12 @@ struct tap_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>&& SenderTo<In, Out>&& SenderTo< (requires Receiver<Out>&& SenderTo<In, Out>&& SenderTo<
In, In,
decltype(::pushmi::detail::receiver_from_fn<In>()(detail::make_tap( decltype(
std::declval<SideEffects>(), ::folly::pushmi::detail::receiver_from_fn<In>()(detail::make_tap(
std::declval<Out>())))>) std::declval<SideEffects>(),
std::declval<Out>())))>)
auto operator()(Out out) const { auto operator()(Out out) const {
auto gang{::pushmi::detail::receiver_from_fn<In>()( auto gang{::folly::pushmi::detail::receiver_from_fn<In>()(
detail::make_tap(sideEffects_, std::move(out)))}; detail::make_tap(sideEffects_, std::move(out)))};
return gang; return gang;
} }
...@@ -125,3 +127,4 @@ PUSHMI_INLINE_VAR constexpr detail::tap_fn tap{}; ...@@ -125,3 +127,4 @@ PUSHMI_INLINE_VAR constexpr detail::tap_fn tap{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/flow_receiver.h> #include <folly/experimental/pushmi/flow_receiver.h>
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -38,19 +39,19 @@ struct transform_on<F, is_single<>> { ...@@ -38,19 +39,19 @@ struct transform_on<F, is_single<>> {
constexpr explicit value_fn(F f) : f_(std::move(f)) {} constexpr explicit value_fn(F f) : f_(std::move(f)) {}
template <class Out, class V0, class... VN> template <class Out, class V0, class... VN>
auto operator()(Out& out, V0&& v0, VN&&... vn) { auto operator()(Out& out, V0&& v0, VN&&... vn) {
using Result = ::pushmi::invoke_result_t<F, V0, VN...>; using Result = ::folly::pushmi::invoke_result_t<F, V0, VN...>;
static_assert( static_assert(
::pushmi::SemiMovable<Result>, ::folly::pushmi::SemiMovable<Result>,
"none of the functions supplied to transform can convert this value"); "none of the functions supplied to transform can convert this value");
static_assert( static_assert(
::pushmi::ReceiveValue<Out, Result>, ::folly::pushmi::ReceiveValue<Out, Result>,
"Result of value transform cannot be delivered to Out"); "Result of value transform cannot be delivered to Out");
::pushmi::set_value(out, f_((V0 &&) v0, (VN &&) vn...)); set_value(out, f_((V0 &&) v0, (VN &&) vn...));
} }
}; };
template <class Out> template <class Out>
auto operator()(Out out) const { auto operator()(Out out) const {
return ::pushmi::make_receiver(std::move(out), value_fn{f_}); return ::folly::pushmi::make_receiver(std::move(out), value_fn{f_});
} }
}; };
...@@ -65,14 +66,15 @@ struct transform_on<F, is_single<>, true> { ...@@ -65,14 +66,15 @@ struct transform_on<F, is_single<>, true> {
} }
template <class Out, class V0, class... VN> template <class Out, class V0, class... VN>
auto operator()(Out& out, V0&& v0, VN&&... vn) { auto operator()(Out& out, V0&& v0, VN&&... vn) {
using Result = ::pushmi::invoke_result_t<F, V0, VN...>; using Result = ::folly::pushmi::invoke_result_t<F, V0, VN...>;
static_assert( static_assert(
::pushmi::SemiMovable<Result>, ::folly::pushmi::SemiMovable<Result>,
"none of the functions supplied to transform can convert this value"); "none of the functions supplied to transform can convert this value");
static_assert( static_assert(
::pushmi::Flow<Out> && ::pushmi::ReceiveValue<Out, Result>, ::folly::pushmi::Flow<Out> &&
::folly::pushmi::ReceiveValue<Out, Result>,
"Result of value transform cannot be delivered to Out"); "Result of value transform cannot be delivered to Out");
::pushmi::set_value(out, f_((V0 &&) v0, (VN &&) vn...)); set_value(out, f_((V0 &&) v0, (VN &&) vn...));
} }
}; };
...@@ -83,18 +85,18 @@ struct transform_on<F, is_many<>> { ...@@ -83,18 +85,18 @@ struct transform_on<F, is_many<>> {
constexpr explicit transform_on(F f) : f_(std::move(f)) {} constexpr explicit transform_on(F f) : f_(std::move(f)) {}
template <class Out> template <class Out>
auto operator()(Out out) const { auto operator()(Out out) const {
return ::pushmi::make_receiver(std::move(out), on_value(*this)); return ::folly::pushmi::make_receiver(std::move(out), on_value(*this));
} }
template <class Out, class V0, class... VN> template <class Out, class V0, class... VN>
auto operator()(Out& out, V0&& v0, VN&&... vn) { auto operator()(Out& out, V0&& v0, VN&&... vn) {
using Result = ::pushmi::invoke_result_t<F, V0, VN...>; using Result = ::folly::pushmi::invoke_result_t<F, V0, VN...>;
static_assert( static_assert(
::pushmi::SemiMovable<Result>, ::folly::pushmi::SemiMovable<Result>,
"none of the functions supplied to transform can convert this value"); "none of the functions supplied to transform can convert this value");
static_assert( static_assert(
::pushmi::ReceiveValue<Out, Result>, ::folly::pushmi::ReceiveValue<Out, Result>,
"Result of value transform cannot be delivered to Out"); "Result of value transform cannot be delivered to Out");
::pushmi::set_value(out, f_((V0 &&) v0, (VN &&) vn...)); set_value(out, f_((V0 &&) v0, (VN &&) vn...));
} }
}; };
...@@ -109,14 +111,15 @@ struct transform_on<F, is_many<>, true> { ...@@ -109,14 +111,15 @@ struct transform_on<F, is_many<>, true> {
} }
template <class Out, class V0, class... VN> template <class Out, class V0, class... VN>
auto operator()(Out& out, V0&& v0, VN&&... vn) { auto operator()(Out& out, V0&& v0, VN&&... vn) {
using Result = ::pushmi::invoke_result_t<F, V0, VN...>; using Result = ::folly::pushmi::invoke_result_t<F, V0, VN...>;
static_assert( static_assert(
::pushmi::SemiMovable<Result>, ::folly::pushmi::SemiMovable<Result>,
"none of the functions supplied to transform can convert this value"); "none of the functions supplied to transform can convert this value");
static_assert( static_assert(
::pushmi::Flow<Out> && ::pushmi::ReceiveValue<Out, Result>, ::folly::pushmi::Flow<Out> &&
::folly::pushmi::ReceiveValue<Out, Result>,
"Result of value transform cannot be delivered to Out"); "Result of value transform cannot be delivered to Out");
::pushmi::set_value(out, f_((V0 &&) v0, (VN &&) vn...)); set_value(out, f_((V0 &&) v0, (VN &&) vn...));
} }
}; };
...@@ -129,9 +132,9 @@ struct transform_fn { ...@@ -129,9 +132,9 @@ struct transform_fn {
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
using Cardinality = property_set_index_t<properties_t<In>, is_single<>>; using Cardinality = property_set_index_t<properties_t<In>, is_single<>>;
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::folly::pushmi::detail::submit_transform_out<In>(
// copy 'f_' to allow multiple calls to connect to multiple 'in' // copy 'f_' to allow multiple calls to connect to multiple 'in'
transform_on< transform_on<
F, F,
...@@ -143,7 +146,7 @@ struct transform_fn { ...@@ -143,7 +146,7 @@ struct transform_fn {
public: public:
template <class... FN> template <class... FN>
auto operator()(FN... fn) const { auto operator()(FN... fn) const {
auto f = ::pushmi::overload(std::move(fn)...); auto f = ::folly::pushmi::overload(std::move(fn)...);
using F = decltype(f); using F = decltype(f);
return impl<F>{std::move(f)}; return impl<F>{std::move(f)};
} }
...@@ -156,3 +159,4 @@ PUSHMI_INLINE_VAR constexpr detail::transform_fn transform{}; ...@@ -156,3 +159,4 @@ PUSHMI_INLINE_VAR constexpr detail::transform_fn transform{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/piping.h> #include <folly/experimental/pushmi/piping.h>
namespace folly {
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -56,7 +57,7 @@ struct via_fn { ...@@ -56,7 +57,7 @@ struct via_fn {
V v_; V v_;
Out out_; Out out_;
void operator()(any) { void operator()(any) {
::pushmi::set_value(out_, std::move(v_)); set_value(out_, std::move(v_));
} }
}; };
template <class Data, class V> template <class Data, class V>
...@@ -64,9 +65,9 @@ struct via_fn { ...@@ -64,9 +65,9 @@ struct via_fn {
if (data.via_fn_base_ref().done) { if (data.via_fn_base_ref().done) {
return; return;
} }
::pushmi::submit( submit(
data.via_fn_base_ref().exec, data.via_fn_base_ref().exec,
::pushmi::make_receiver(impl<std::decay_t<V>>{ ::folly::pushmi::make_receiver(impl<std::decay_t<V>>{
(V &&) v, std::move(static_cast<Out&>(data))})); (V &&) v, std::move(static_cast<Out&>(data))}));
} }
}; };
...@@ -77,7 +78,7 @@ struct via_fn { ...@@ -77,7 +78,7 @@ struct via_fn {
E e_; E e_;
Out out_; Out out_;
void operator()(any) noexcept { void operator()(any) noexcept {
::pushmi::set_error(out_, std::move(e_)); set_error(out_, std::move(e_));
} }
}; };
template <class Data, class E> template <class Data, class E>
...@@ -86,9 +87,9 @@ struct via_fn { ...@@ -86,9 +87,9 @@ struct via_fn {
return; return;
} }
data.via_fn_base_ref().done = true; data.via_fn_base_ref().done = true;
::pushmi::submit( submit(
data.via_fn_base_ref().exec, data.via_fn_base_ref().exec,
::pushmi::make_receiver( ::folly::pushmi::make_receiver(
impl<E>{std::move(e), std::move(static_cast<Out&>(data))})); impl<E>{std::move(e), std::move(static_cast<Out&>(data))}));
} }
}; };
...@@ -97,7 +98,7 @@ struct via_fn { ...@@ -97,7 +98,7 @@ struct via_fn {
struct impl { struct impl {
Out out_; Out out_;
void operator()(any) { void operator()(any) {
::pushmi::set_done(out_); set_done(out_);
} }
}; };
template <class Data> template <class Data>
...@@ -106,9 +107,10 @@ struct via_fn { ...@@ -106,9 +107,10 @@ struct via_fn {
return; return;
} }
data.via_fn_base_ref().done = true; data.via_fn_base_ref().done = true;
::pushmi::submit( submit(
data.via_fn_base_ref().exec, data.via_fn_base_ref().exec,
::pushmi::make_receiver(impl{std::move(static_cast<Out&>(data))})); ::folly::pushmi::make_receiver(
impl{std::move(static_cast<Out&>(data))}));
} }
}; };
template <class In, class ExecutorFactory> template <class In, class ExecutorFactory>
...@@ -126,7 +128,7 @@ struct via_fn { ...@@ -126,7 +128,7 @@ struct via_fn {
(requires Receiver<Out>) (requires Receiver<Out>)
auto operator()(Out out) const { auto operator()(Out out) const {
auto exec = ef_(); auto exec = ef_();
return ::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
make_via_fn_data(std::move(out), std::move(exec)), make_via_fn_data(std::move(out), std::move(exec)),
on_value_impl<Out>{}, on_value_impl<Out>{},
on_error_impl<Out>{}, on_error_impl<Out>{},
...@@ -139,11 +141,12 @@ struct via_fn { ...@@ -139,11 +141,12 @@ struct via_fn {
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::folly::pushmi::detail::submit_transform_out<In>(
out_impl<In, ExecutorFactory>{ef_}), out_impl<In, ExecutorFactory>{ef_}),
::pushmi::on_executor(executor_impl<In, ExecutorFactory>{ef_})); ::folly::pushmi::on_executor(
executor_impl<In, ExecutorFactory>{ef_}));
} }
}; };
...@@ -164,3 +167,4 @@ PUSHMI_INLINE_VAR constexpr detail::via_fn via{}; ...@@ -164,3 +167,4 @@ PUSHMI_INLINE_VAR constexpr detail::via_fn via{};
} // namespace operators } // namespace operators
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/traits.h> #include <folly/experimental/pushmi/traits.h>
namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_TEMPLATE(class In, class Op) PUSHMI_TEMPLATE(class In, class Op)
...@@ -45,3 +46,4 @@ PUSHMI_INLINE_VAR constexpr struct pipe_fn { ...@@ -45,3 +46,4 @@ PUSHMI_INLINE_VAR constexpr struct pipe_fn {
} const pipe{}; } const pipe{};
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,9 +13,11 @@ ...@@ -14,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/traits.h> #include <folly/experimental/pushmi/traits.h>
namespace folly {
namespace pushmi { namespace pushmi {
// property_set implements a map of category-type to property-type. // property_set implements a map of category-type to property-type.
...@@ -199,3 +200,4 @@ PUSHMI_INLINE_VAR constexpr bool category_query_v = ...@@ -199,3 +200,4 @@ PUSHMI_INLINE_VAR constexpr bool category_query_v =
category_query<PS, ExpectedN...>::value; category_query<PS, ExpectedN...>::value;
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,10 +13,19 @@ ...@@ -14,10 +13,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/boosters.h> #include <folly/experimental/pushmi/boosters.h>
#include <folly/experimental/pushmi/concepts.h>
#include <folly/experimental/pushmi/detail/concept_def.h>
#include <folly/experimental/pushmi/detail/functional.h>
#include <folly/experimental/pushmi/extension_points.h>
#include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/properties.h>
#include <folly/experimental/pushmi/traits.h>
#include <future> #include <future>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class... VN> template <class E, class... VN>
...@@ -57,7 +65,7 @@ class any_receiver { ...@@ -57,7 +65,7 @@ class any_receiver {
ReceiveError<Wrapped, std::exception_ptr>, ReceiveError<Wrapped, std::exception_ptr>,
"Wrapped receiver must support std::exception_ptr and be noexcept"); "Wrapped receiver must support std::exception_ptr and be noexcept");
static_assert( static_assert(
NothrowInvocable<decltype(::pushmi::set_error), Wrapped, E>, NothrowInvocable<decltype(::folly::pushmi::set_error), Wrapped, E>,
"Wrapped receiver must support E and be noexcept"); "Wrapped receiver must support E and be noexcept");
} }
template <class Wrapped> template <class Wrapped>
...@@ -69,14 +77,13 @@ class any_receiver { ...@@ -69,14 +77,13 @@ class any_receiver {
delete static_cast<Wrapped const*>(src.pobj_); delete static_cast<Wrapped const*>(src.pobj_);
} }
static void done(data& src) { static void done(data& src) {
::pushmi::set_done(*static_cast<Wrapped*>(src.pobj_)); set_done(*static_cast<Wrapped*>(src.pobj_));
} }
static void error(data& src, E e) noexcept { static void error(data& src, E e) noexcept {
::pushmi::set_error(*static_cast<Wrapped*>(src.pobj_), std::move(e)); set_error(*static_cast<Wrapped*>(src.pobj_), std::move(e));
} }
static void value(data& src, VN... vn) { static void value(data& src, VN... vn) {
::pushmi::set_value( set_value(*static_cast<Wrapped*>(src.pobj_), std::move(vn)...);
*static_cast<Wrapped*>(src.pobj_), std::move(vn)...);
} }
}; };
static const vtable vtbl{s::op, s::done, s::error, s::value}; static const vtable vtbl{s::op, s::done, s::error, s::value};
...@@ -93,15 +100,13 @@ class any_receiver { ...@@ -93,15 +100,13 @@ class any_receiver {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static void done(data& src) { static void done(data& src) {
::pushmi::set_done(*static_cast<Wrapped*>((void*)src.buffer_)); set_done(*static_cast<Wrapped*>((void*)src.buffer_));
} }
static void error(data& src, E e) noexcept { static void error(data& src, E e) noexcept {
::pushmi::set_error( set_error(*static_cast<Wrapped*>((void*)src.buffer_), std::move(e));
*static_cast<Wrapped*>((void*)src.buffer_), std::move(e));
} }
static void value(data& src, VN... vn) { static void value(data& src, VN... vn) {
::pushmi::set_value( set_value(*static_cast<Wrapped*>((void*)src.buffer_), std::move(vn)...);
*static_cast<Wrapped*>((void*)src.buffer_), std::move(vn)...);
} }
}; };
static const vtable vtbl{s::op, s::done, s::error, s::value}; static const vtable vtbl{s::op, s::done, s::error, s::value};
...@@ -508,3 +513,4 @@ std::future<void> future_from(In in) { ...@@ -508,3 +513,4 @@ std::future<void> future_from(In in) {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,11 +13,13 @@ ...@@ -14,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class... VN> template <class E, class... VN>
...@@ -54,10 +55,11 @@ class any_single_sender { ...@@ -54,10 +55,11 @@ class any_single_sender {
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{
::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))}; ::folly::pushmi::executor(*static_cast<Wrapped*>(src.pobj_))};
} }
static void submit(data& src, any_receiver<E, VN...> out) { static void submit(data& src, any_receiver<E, VN...> out) {
::pushmi::submit(*static_cast<Wrapped*>(src.pobj_), std::move(out)); ::folly::pushmi::submit(
*static_cast<Wrapped*>(src.pobj_), std::move(out));
} }
}; };
static const vtable vtbl{s::op, s::executor, s::submit}; static const vtable vtbl{s::op, s::executor, s::submit};
...@@ -75,11 +77,11 @@ class any_single_sender { ...@@ -75,11 +77,11 @@ class any_single_sender {
static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped(); static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
} }
static any_executor<E> executor(data& src) { static any_executor<E> executor(data& src) {
return any_executor<E>{ return any_executor<E>{::folly::pushmi::executor(
::pushmi::executor(*static_cast<Wrapped*>((void*)src.buffer_))}; *static_cast<Wrapped*>((void*)src.buffer_))};
} }
static void submit(data& src, any_receiver<E, VN...> out) { static void submit(data& src, any_receiver<E, VN...> out) {
::pushmi::submit( ::folly::pushmi::submit(
*static_cast<Wrapped*>((void*)src.buffer_), std::move(out)); *static_cast<Wrapped*>((void*)src.buffer_), std::move(out));
} }
}; };
...@@ -105,8 +107,8 @@ class any_single_sender { ...@@ -105,8 +107,8 @@ class any_single_sender {
wrapped_t<Wrapped>, wrapped_t<Wrapped>,
any_receiver< any_receiver<
E, E,
VN...>>) VN...>>)explicit any_single_sender(Wrapped
explicit any_single_sender(Wrapped obj) noexcept(insitu<Wrapped>()) obj) noexcept(insitu<Wrapped>())
: any_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : any_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_single_sender() { ~any_single_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
...@@ -258,3 +260,4 @@ template<> ...@@ -258,3 +260,4 @@ template<>
struct construct_deduced<single_sender> : make_single_sender_fn {}; struct construct_deduced<single_sender> : make_single_sender_fn {};
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/single_sender.h> #include <folly/experimental/pushmi/single_sender.h>
#include <queue> #include <queue>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class Executor> template <class E, class Executor>
...@@ -119,8 +120,8 @@ class strand_queue : public strand_queue_base<E> { ...@@ -119,8 +120,8 @@ class strand_queue : public strand_queue_base<E> {
auto item{std::move(this->front())}; auto item{std::move(this->front())};
this->items_.pop(); this->items_.pop();
guard.unlock(); guard.unlock();
::pushmi::set_value(item.what, any_executor_ref<E>{subEx}); set_value(item.what, any_executor_ref<E>{subEx});
::pushmi::set_done(item.what); set_done(item.what);
guard.lock(); guard.lock();
} }
} }
...@@ -134,7 +135,7 @@ class strand_queue : public strand_queue_base<E> { ...@@ -134,7 +135,7 @@ class strand_queue : public strand_queue_base<E> {
auto what{std::move(this->front().what)}; auto what{std::move(this->front().what)};
this->items_.pop(); this->items_.pop();
guard.unlock(); guard.unlock();
::pushmi::set_error(what, detail::as_const(e)); set_error(what, detail::as_const(e));
guard.lock(); guard.lock();
} }
} }
...@@ -151,7 +152,7 @@ class strand_queue : public strand_queue_base<E> { ...@@ -151,7 +152,7 @@ class strand_queue : public strand_queue_base<E> {
} }
auto that = shared_from_that(); auto that = shared_from_that();
::pushmi::submit(ex_, strand_queue_receiver<E, Executor>{that}); submit(ex_, strand_queue_receiver<E, Executor>{that});
} }
}; };
...@@ -166,7 +167,7 @@ struct strand_queue_receiver : std::shared_ptr<strand_queue<E, Executor>> { ...@@ -166,7 +167,7 @@ struct strand_queue_receiver : std::shared_ptr<strand_queue<E, Executor>> {
template <class E, class Executor> template <class E, class Executor>
void strand_queue<E, Executor>::dispatch() { void strand_queue<E, Executor>::dispatch() {
::pushmi::submit(ex_, strand_queue_receiver<E, Executor>{shared_from_that()}); submit(ex_, strand_queue_receiver<E, Executor>{shared_from_that()});
} }
// //
...@@ -202,7 +203,7 @@ class strand_executor { ...@@ -202,7 +203,7 @@ class strand_executor {
queue_->items_.push(any_receiver<E, any_executor_ref<E>>{std::move(out)}); queue_->items_.push(any_receiver<E, any_executor_ref<E>>{std::move(out)});
if (queue_->remaining_ == 0) { if (queue_->remaining_ == 0) {
// noone is minding the shop, send a worker // noone is minding the shop, send a worker
::pushmi::submit(queue_->ex_, strand_queue_receiver<E, Executor>{queue_}); submit(queue_->ex_, strand_queue_receiver<E, Executor>{queue_});
} }
} }
}; };
...@@ -252,3 +253,4 @@ auto strands(Exec ex) { ...@@ -252,3 +253,4 @@ auto strands(Exec ex) {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <vector> #include <vector>
#include <folly/experimental/pushmi/time_single_sender.h> #include <folly/experimental/pushmi/time_single_sender.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class... TN> template <class... TN>
...@@ -34,7 +35,7 @@ struct subject<PS, TN...> { ...@@ -34,7 +35,7 @@ struct subject<PS, TN...> {
struct subject_shared { struct subject_shared {
using receiver_t = any_receiver<std::exception_ptr, TN...>; using receiver_t = any_receiver<std::exception_ptr, TN...>;
bool done_ = false; bool done_ = false;
pushmi::detail::opt<std::tuple<std::decay_t<TN>...>> t_; ::folly::pushmi::detail::opt<std::tuple<std::decay_t<TN>...>> t_;
std::exception_ptr ep_; std::exception_ptr ep_;
std::vector<receiver_t> receivers_; std::vector<receiver_t> receivers_;
std::mutex lock_; std::mutex lock_;
...@@ -43,18 +44,18 @@ struct subject<PS, TN...> { ...@@ -43,18 +44,18 @@ struct subject<PS, TN...> {
void submit(Out out) { void submit(Out out) {
std::unique_lock<std::mutex> guard(lock_); std::unique_lock<std::mutex> guard(lock_);
if (ep_) { if (ep_) {
::pushmi::set_error(out, ep_); set_error(out, ep_);
return; return;
} }
if (!!t_) { if (!!t_) {
auto args = *t_; auto args = *t_;
::pushmi::apply( ::folly::pushmi::apply(
::pushmi::set_value, ::folly::pushmi::set_value,
std::tuple_cat(std::tuple<Out>{std::move(out)}, std::move(args))); std::tuple_cat(std::tuple<Out>{std::move(out)}, std::move(args)));
return; return;
} }
if (done_) { if (done_) {
::pushmi::set_done(out); set_done(out);
return; return;
} }
receivers_.push_back(receiver_t{out}); receivers_.push_back(receiver_t{out});
...@@ -64,8 +65,8 @@ struct subject<PS, TN...> { ...@@ -64,8 +65,8 @@ struct subject<PS, TN...> {
void value(VN&&... vn) { void value(VN&&... vn) {
std::unique_lock<std::mutex> guard(lock_); std::unique_lock<std::mutex> guard(lock_);
for (auto& out : receivers_) { for (auto& out : receivers_) {
::pushmi::apply( ::folly::pushmi::apply(
::pushmi::set_value, ::folly::pushmi::set_value,
std::tuple<decltype(out), std::decay_t<TN>...>{ std::tuple<decltype(out), std::decay_t<TN>...>{
out, detail::as_const(vn)...}); out, detail::as_const(vn)...});
} }
...@@ -78,7 +79,7 @@ struct subject<PS, TN...> { ...@@ -78,7 +79,7 @@ struct subject<PS, TN...> {
std::unique_lock<std::mutex> guard(lock_); std::unique_lock<std::mutex> guard(lock_);
ep_ = e; ep_ = e;
for (auto& out : receivers_) { for (auto& out : receivers_) {
::pushmi::set_error(out, std::move(e)); set_error(out, std::move(e));
} }
receivers_.clear(); receivers_.clear();
} }
...@@ -86,7 +87,7 @@ struct subject<PS, TN...> { ...@@ -86,7 +87,7 @@ struct subject<PS, TN...> {
std::unique_lock<std::mutex> guard(lock_); std::unique_lock<std::mutex> guard(lock_);
done_ = true; done_ = true;
for (auto& out : receivers_) { for (auto& out : receivers_) {
::pushmi::set_done(out); set_done(out);
} }
receivers_.clear(); receivers_.clear();
} }
...@@ -129,3 +130,4 @@ struct subject<PS, TN...> { ...@@ -129,3 +130,4 @@ struct subject<PS, TN...> {
}; };
} // namespace pushmi } // namespace pushmi
} // namespace folly
...@@ -31,7 +31,7 @@ using namespace std::literals; ...@@ -31,7 +31,7 @@ using namespace std::literals;
#include <folly/experimental/pushmi/time_source.h> #include <folly/experimental/pushmi/time_source.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
#if 0 #if 0
......
...@@ -27,7 +27,7 @@ using namespace std::literals; ...@@ -27,7 +27,7 @@ using namespace std::literals;
#include <folly/experimental/pushmi/time_source.h> #include <folly/experimental/pushmi/time_source.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
#if 0 #if 0
......
...@@ -33,7 +33,7 @@ using namespace std::literals; ...@@ -33,7 +33,7 @@ using namespace std::literals;
#include <folly/experimental/pushmi/time_source.h> #include <folly/experimental/pushmi/time_source.h>
#include <folly/experimental/pushmi/strand.h> #include <folly/experimental/pushmi/strand.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
#if 0 #if 0
struct countdownsingle { struct countdownsingle {
...@@ -160,8 +160,8 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) { ...@@ -160,8 +160,8 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) {
WHEN( "virtual derecursion is triggered" ) { WHEN( "virtual derecursion is triggered" ) {
int counter = 100'000; int counter = 100'000;
std::function<void(pushmi::any_executor_ref<> exec)> recurse; std::function<void(::folly::pushmi::any_executor_ref<> exec)> recurse;
recurse = [&](pushmi::any_executor_ref<> nt) { recurse = [&](::folly::pushmi::any_executor_ref<> nt) {
if (--counter <= 0) if (--counter <= 0)
return; return;
nt | op::submit(recurse); nt | op::submit(recurse);
...@@ -184,13 +184,13 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) { ...@@ -184,13 +184,13 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) {
WHEN( "used with on" ) { WHEN( "used with on" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto sender = pushmi::make_single_sender([](auto out) { auto sender = ::folly::pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::folly::pushmi::set_value(out, 2.0);
::pushmi::set_done(out); ::folly::pushmi::set_done(out);
// ignored // ignored
::pushmi::set_value(out, 1); ::folly::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
sender | op::on([&](){return nt;}) | sender | op::on([&](){return nt;}) |
op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
...@@ -201,13 +201,13 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) { ...@@ -201,13 +201,13 @@ SCENARIO( "new_thread executor", "[new_thread][sender]" ) {
WHEN( "used with via" ) { WHEN( "used with via" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto sender = pushmi::make_single_sender([](auto out) { auto sender = ::folly::pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::folly::pushmi::set_value(out, 2.0);
::pushmi::set_done(out); ::folly::pushmi::set_done(out);
// ignored // ignored
::pushmi::set_value(out, 1); ::folly::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
sender | op::via(mi::strands(nt)) | sender | op::via(mi::strands(nt)) |
op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
......
...@@ -21,18 +21,18 @@ using namespace std::literals; ...@@ -21,18 +21,18 @@ using namespace std::literals;
#include <folly/experimental/pushmi/flow_single_sender.h> #include <folly/experimental/pushmi/flow_single_sender.h>
#include <folly/experimental/pushmi/o/empty.h> #include <folly/experimental/pushmi/o/empty.h>
#include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/from.h> #include <folly/experimental/pushmi/o/from.h>
#include <folly/experimental/pushmi/o/just.h> #include <folly/experimental/pushmi/o/just.h>
#include <folly/experimental/pushmi/o/on.h> #include <folly/experimental/pushmi/o/on.h>
#include <folly/experimental/pushmi/o/transform.h>
#include <folly/experimental/pushmi/o/tap.h>
#include <folly/experimental/pushmi/o/submit.h> #include <folly/experimental/pushmi/o/submit.h>
#include <folly/experimental/pushmi/o/extension_operators.h> #include <folly/experimental/pushmi/o/tap.h>
#include <folly/experimental/pushmi/o/transform.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
#include <folly/experimental/pushmi/new_thread.h> #include <folly/experimental/pushmi/new_thread.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
#if 0 #if 0
SCENARIO( "empty can be used with tap and submit", "[empty][sender]" ) { SCENARIO( "empty can be used with tap and submit", "[empty][sender]" ) {
......
...@@ -32,7 +32,7 @@ using namespace std::literals; ...@@ -32,7 +32,7 @@ using namespace std::literals;
#include <folly/experimental/pushmi/inline.h> #include <folly/experimental/pushmi/inline.h>
#include <folly/experimental/pushmi/trampoline.h> #include <folly/experimental/pushmi/trampoline.h>
using namespace pushmi::aliases; using namespace folly::pushmi::aliases;
#if 0 #if 0
struct countdownsingle { struct countdownsingle {
...@@ -82,8 +82,8 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) { ...@@ -82,8 +82,8 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) {
WHEN( "virtual derecursion is triggered" ) { WHEN( "virtual derecursion is triggered" ) {
int counter = 100'000; int counter = 100'000;
std::function<void(pushmi::any_executor_ref<> exec)> recurse; std::function<void(::folly::pushmi::any_executor_ref<> exec)> recurse;
recurse = [&](pushmi::any_executor_ref<> tr) { recurse = [&](::folly::pushmi::any_executor_ref<> tr) {
if (--counter <= 0) if (--counter <= 0)
return; return;
tr | op::submit(recurse); tr | op::submit(recurse);
...@@ -106,13 +106,13 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) { ...@@ -106,13 +106,13 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) {
WHEN( "used with on" ) { WHEN( "used with on" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto sender = pushmi::make_single_sender([](auto out) { auto sender = ::folly::pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::folly::pushmi::set_value(out, 2.0);
::pushmi::set_done(out); ::folly::pushmi::set_done(out);
// ignored // ignored
::pushmi::set_value(out, 1); ::folly::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
auto inlineon = sender | op::on([&](){return mi::inline_executor();}); auto inlineon = sender | op::on([&](){return mi::inline_executor();});
inlineon | inlineon |
...@@ -127,13 +127,13 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) { ...@@ -127,13 +127,13 @@ SCENARIO( "trampoline executor", "[trampoline][sender]" ) {
WHEN( "used with via" ) { WHEN( "used with via" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto sender = pushmi::make_single_sender([](auto out) { auto sender = ::folly::pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::folly::pushmi::set_value(out, 2.0);
::pushmi::set_done(out); ::folly::pushmi::set_done(out);
// ignored // ignored
::pushmi::set_value(out, 1); ::folly::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::folly::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
auto inlinevia = sender | op::via([&](){return mi::inline_executor();}); auto inlinevia = sender | op::via([&](){return mi::inline_executor();});
inlinevia | inlinevia |
......
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,12 +13,14 @@ ...@@ -14,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/receiver.h> #include <folly/experimental/pushmi/receiver.h>
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/inline.h> #include <folly/experimental/pushmi/inline.h>
#include <folly/experimental/pushmi/constrained_single_sender.h> #include <folly/experimental/pushmi/constrained_single_sender.h>
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class TP, class... VN> template <class E, class TP, class... VN>
...@@ -172,4 +173,5 @@ template<> ...@@ -172,4 +173,5 @@ template<>
struct construct_deduced<time_single_sender> struct construct_deduced<time_single_sender>
: make_time_single_sender_fn {}; : make_time_single_sender_fn {};
} //namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <folly/experimental/pushmi/time_single_sender.h> #include <folly/experimental/pushmi/time_single_sender.h>
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
// time_source is used to build a time_single_executor from a single_executor. // time_source is used to build a time_single_executor from a single_executor.
// //
namespace folly {
namespace pushmi { namespace pushmi {
template <class E, class TP> template <class E, class TP>
...@@ -154,8 +155,8 @@ class time_source_queue : public time_source_queue_base<E, TP> { ...@@ -154,8 +155,8 @@ class time_source_queue : public time_source_queue_base<E, TP> {
this->heap_.pop(); this->heap_.pop();
guard.unlock(); guard.unlock();
std::this_thread::sleep_until(item.when); std::this_thread::sleep_until(item.when);
::pushmi::set_value(item.what, any_time_executor_ref<E, TP>{subEx}); set_value(item.what, any_time_executor_ref<E, TP>{subEx});
::pushmi::set_done(item.what); set_done(item.what);
guard.lock(); guard.lock();
// allows set_value to queue nested items // allows set_value to queue nested items
--s->items_; --s->items_;
...@@ -173,7 +174,7 @@ class time_source_queue : public time_source_queue_base<E, TP> { ...@@ -173,7 +174,7 @@ class time_source_queue : public time_source_queue_base<E, TP> {
this->heap_.pop(); this->heap_.pop();
--s->items_; --s->items_;
guard.unlock(); guard.unlock();
::pushmi::set_error(what, *s->error_); set_error(what, *s->error_);
guard.lock(); guard.lock();
} catch (...) { } catch (...) {
// we already have an error, ignore this one. // we already have an error, ignore this one.
...@@ -196,7 +197,7 @@ class time_source_queue : public time_source_queue_base<E, TP> { ...@@ -196,7 +197,7 @@ class time_source_queue : public time_source_queue_base<E, TP> {
this->heap_.pop(); this->heap_.pop();
--s->items_; --s->items_;
guard.unlock(); guard.unlock();
::pushmi::set_error(what, detail::as_const(e)); set_error(what, detail::as_const(e));
guard.lock(); guard.lock();
} }
this->dispatching_ = false; this->dispatching_ = false;
...@@ -235,7 +236,7 @@ struct time_source_queue_receiver ...@@ -235,7 +236,7 @@ struct time_source_queue_receiver
template <class E, class TP, class NF, class Executor> template <class E, class TP, class NF, class Executor>
void time_source_queue<E, TP, NF, Executor>::dispatch() { void time_source_queue<E, TP, NF, Executor>::dispatch() {
::pushmi::submit( submit(
ex_, time_source_queue_receiver<E, TP, NF, Executor>{shared_from_that()}); ex_, time_source_queue_receiver<E, TP, NF, Executor>{shared_from_that()});
} }
...@@ -389,7 +390,7 @@ class time_source_shared : public time_source_shared_base<E, TP> { ...@@ -389,7 +390,7 @@ class time_source_shared : public time_source_shared_base<E, TP> {
q->heap_.pop(); q->heap_.pop();
--that->items_; --that->items_;
guard.unlock(); guard.unlock();
::pushmi::set_error(what, *that->error_); set_error(what, *that->error_);
guard.lock(); guard.lock();
} catch (...) { } catch (...) {
// we already have an error, ignore this one. // we already have an error, ignore this one.
...@@ -406,7 +407,7 @@ class time_source_shared : public time_source_shared_base<E, TP> { ...@@ -406,7 +407,7 @@ class time_source_shared : public time_source_shared_base<E, TP> {
// deliver error_ and return // deliver error_ and return
if (!!this->error_) { if (!!this->error_) {
::pushmi::set_error(item.what, *this->error_); set_error(item.what, *this->error_);
return; return;
} }
// once join() is called, new work queued to the executor is not safe unless // once join() is called, new work queued to the executor is not safe unless
...@@ -551,3 +552,4 @@ class time_source { ...@@ -551,3 +552,4 @@ class time_source {
} }
}; };
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <functional> #include <functional>
#include <type_traits> #include <type_traits>
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
}\ }\
/**/ /**/
namespace folly {
namespace pushmi { namespace pushmi {
#if __cpp_fold_expressions >= 201603 #if __cpp_fold_expressions >= 201603
template <bool... Bs> template <bool... Bs>
...@@ -231,3 +232,4 @@ PUSHMI_INLINE_VAR constexpr struct as_const_fn { ...@@ -231,3 +232,4 @@ PUSHMI_INLINE_VAR constexpr struct as_const_fn {
} // namespace detail } // namespace detail
} // namespace pushmi } // namespace pushmi
} // namespace folly
#pragma once
/* /*
* Copyright 2018-present Facebook, Inc. * Copyright 2018-present Facebook, Inc.
* *
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once
#include <folly/experimental/pushmi/executor.h> #include <folly/experimental/pushmi/executor.h>
#include <algorithm> #include <algorithm>
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <deque> #include <deque>
#include <thread> #include <thread>
namespace folly {
namespace pushmi { namespace pushmi {
struct recurse_t {}; struct recurse_t {};
...@@ -152,8 +153,8 @@ class trampoline { ...@@ -152,8 +153,8 @@ class trampoline {
} else { } else {
// dynamic recursion - optimization to balance queueing and // dynamic recursion - optimization to balance queueing and
// stack usage and value interleaving on the same thread. // stack usage and value interleaving on the same thread.
::pushmi::set_value(awhat, that); set_value(awhat, that);
::pushmi::set_done(awhat); set_done(awhat);
} }
} catch (...) { } catch (...) {
--depth(*owner()); --depth(*owner());
...@@ -175,9 +176,9 @@ class trampoline { ...@@ -175,9 +176,9 @@ class trampoline {
} catch (...) { } catch (...) {
// ignore exceptions while delivering the exception // ignore exceptions while delivering the exception
try { try {
::pushmi::set_error(awhat, std::current_exception()); set_error(awhat, std::current_exception());
for (auto& what : pending(pending_store)) { for (auto& what : pending(pending_store)) {
::pushmi::set_error(what, std::current_exception()); set_error(what, std::current_exception());
} }
} catch (...) { } catch (...) {
} }
...@@ -220,8 +221,8 @@ class trampoline { ...@@ -220,8 +221,8 @@ class trampoline {
bool go = true; bool go = true;
while (go) { while (go) {
repeat(pending_store) = false; repeat(pending_store) = false;
::pushmi::set_value(awhat, that); set_value(awhat, that);
::pushmi::set_done(awhat); set_done(awhat);
go = repeat(pending_store); go = repeat(pending_store);
} }
} else { } else {
...@@ -235,8 +236,8 @@ class trampoline { ...@@ -235,8 +236,8 @@ class trampoline {
while (!pending(pending_store).empty()) { while (!pending(pending_store).empty()) {
auto what = std::move(pending(pending_store).front()); auto what = std::move(pending(pending_store).front());
pending(pending_store).pop_front(); pending(pending_store).pop_front();
::pushmi::set_value(what, any_executor_ref<error_type>{that}); set_value(what, any_executor_ref<error_type>{that});
::pushmi::set_done(what); set_done(what);
} }
} }
}; };
...@@ -277,7 +278,7 @@ namespace detail { ...@@ -277,7 +278,7 @@ namespace detail {
PUSHMI_TEMPLATE(class E) PUSHMI_TEMPLATE(class E)
(requires SenderTo<delegator<E>, recurse_t>) (requires SenderTo<delegator<E>, recurse_t>)
decltype(auto) repeat(delegator<E>& exec) { decltype(auto) repeat(delegator<E>& exec) {
::pushmi::submit(exec, recurse); submit(exec, recurse);
} }
template <class AnyExec> template <class AnyExec>
[[noreturn]] void repeat(AnyExec&) { [[noreturn]] void repeat(AnyExec&) {
...@@ -291,3 +292,4 @@ inline auto repeat() { ...@@ -291,3 +292,4 @@ inline auto repeat() {
} }
} // namespace pushmi } // namespace pushmi
} // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment