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