Commit fbc1a619 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

rename many_sender to simply sender

Summary: To reflect the fact that the concept `SingleSender` is a refinement of `Sender` (there is no "`ManySender`"), rename `(any_)?(flow_)?many_sender` to `(any_)?(flow_)?sender`.

Reviewed By: kirkshoop

Differential Revision: D14803648

fbshipit-source-id: 5987ebe5ba877d0a3ab38e84b036f97302bcc70b
parent bb73ffc6
......@@ -56,13 +56,13 @@ template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class single_sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class many_sender;
class sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class flow_single_sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class flow_many_sender;
class flow_sender;
template <class E = std::exception_ptr, class... VN>
class any_receiver;
......@@ -78,7 +78,7 @@ template <class E = std::exception_ptr, class... VN>
class any_single_sender;
template <class E = std::exception_ptr, class... VN>
class any_many_sender;
class any_sender;
template <class PE = std::exception_ptr, class E = PE, class... VN>
class any_flow_single_sender;
......@@ -88,7 +88,7 @@ template <
class PV = std::ptrdiff_t,
class E = PE,
class... VN>
class any_flow_many_sender;
class any_flow_sender;
template <class E = std::exception_ptr>
class any_executor;
......@@ -148,13 +148,13 @@ template<>
struct construct_deduced<single_sender>;
template<>
struct construct_deduced<many_sender>;
struct construct_deduced<sender>;
template<>
struct construct_deduced<flow_single_sender>;
template<>
struct construct_deduced<flow_many_sender>;
struct construct_deduced<flow_sender>;
} // namespace pushmi
} // namespace folly
......@@ -27,11 +27,11 @@
#include <folly/experimental/pushmi/executor/executor.h>
#include <folly/experimental/pushmi/executor/inline.h>
#include <folly/experimental/pushmi/executor/trampoline.h>
#include <folly/experimental/pushmi/sender/flow_many_sender.h>
#include <folly/experimental/pushmi/sender/flow_sender.h>
#include <folly/experimental/pushmi/receiver/flow_receiver.h>
#include <folly/experimental/pushmi/sender/flow_single_sender.h>
#include <folly/experimental/pushmi/forwards.h>
#include <folly/experimental/pushmi/sender/many_sender.h>
#include <folly/experimental/pushmi/sender/sender.h>
#include <folly/experimental/pushmi/piping.h>
#include <folly/experimental/pushmi/properties.h>
#include <folly/experimental/pushmi/receiver/receiver.h>
......@@ -121,13 +121,13 @@ struct make_sender;
template <>
struct make_sender<single_sender_tag> : construct_deduced<single_sender> {};
template <>
struct make_sender<sender_tag> : construct_deduced<many_sender> {};
struct make_sender<sender_tag> : construct_deduced<sender> {};
template <>
struct make_sender<flow_single_sender_tag>
: construct_deduced<flow_single_sender> {};
template <>
struct make_sender<flow_sender_tag>
: construct_deduced<flow_many_sender> {};
: construct_deduced<flow_sender> {};
PUSHMI_INLINE_VAR constexpr struct sender_from_fn {
PUSHMI_TEMPLATE(class In, class... FN)
......
......@@ -15,8 +15,8 @@
*/
#pragma once
#include <folly/experimental/pushmi/sender/flow_many_sender.h>
#include <folly/experimental/pushmi/sender/many_sender.h>
#include <folly/experimental/pushmi/sender/flow_sender.h>
#include <folly/experimental/pushmi/sender/sender.h>
#include <folly/experimental/pushmi/sender/properties.h>
#include <folly/experimental/pushmi/o/extension_operators.h>
#include <folly/experimental/pushmi/o/submit.h>
......
......@@ -28,7 +28,7 @@ namespace folly {
namespace pushmi {
template <class PE, class PV, class E, class... VN>
class any_flow_many_sender
class any_flow_sender
: public flow_sender_tag::with_values<VN...>::template with_error<E> {
using insitu_t = void*[2];
union data {
......@@ -49,7 +49,7 @@ class any_flow_many_sender
static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_;
template <class Wrapped>
any_flow_many_sender(Wrapped obj, std::false_type) : any_flow_many_sender() {
any_flow_sender(Wrapped obj, std::false_type) : any_flow_sender() {
struct s {
static void op(data& src, data* dst) {
if (dst)
......@@ -66,8 +66,8 @@ class any_flow_many_sender
vptr_ = &vtbl;
}
template <class Wrapped>
any_flow_many_sender(Wrapped obj, std::true_type) noexcept
: any_flow_many_sender() {
any_flow_sender(Wrapped obj, std::true_type) noexcept
: any_flow_sender() {
struct s {
static void op(data& src, data* dst) {
if (dst)
......@@ -86,24 +86,24 @@ class any_flow_many_sender
}
template <class T, class U = std::decay_t<T>>
using wrapped_t =
std::enable_if_t<!std::is_same<U, any_flow_many_sender>::value, U>;
std::enable_if_t<!std::is_same<U, any_flow_sender>::value, U>;
public:
any_flow_many_sender() = default;
any_flow_many_sender(any_flow_many_sender&& that) noexcept
: any_flow_many_sender() {
any_flow_sender() = default;
any_flow_sender(any_flow_sender&& that) noexcept
: any_flow_sender() {
that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_);
}
PUSHMI_TEMPLATE (class Wrapped)
(requires FlowSender<wrapped_t<Wrapped>>)
explicit any_flow_many_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_flow_many_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_flow_many_sender() {
explicit any_flow_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_flow_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_flow_sender() {
vptr_->op_(data_, nullptr);
}
any_flow_many_sender& operator=(any_flow_many_sender&& that) noexcept {
this->~any_flow_many_sender();
new ((void*)this) any_flow_many_sender(std::move(that));
any_flow_sender& operator=(any_flow_sender&& that) noexcept {
this->~any_flow_sender();
new ((void*)this) any_flow_sender(std::move(that));
return *this;
}
PUSHMI_TEMPLATE(class Out)
......@@ -115,18 +115,18 @@ class any_flow_many_sender
// Class static definitions:
template <class PE, class PV, class E, class... VN>
constexpr typename any_flow_many_sender<PE, PV, E, VN...>::vtable const
any_flow_many_sender<PE, PV, E, VN...>::noop_;
constexpr typename any_flow_sender<PE, PV, E, VN...>::vtable const
any_flow_sender<PE, PV, E, VN...>::noop_;
template <class SF>
class flow_many_sender<SF> {
class flow_sender<SF> {
SF sf_;
public:
using sender_category = flow_sender_tag;
constexpr flow_many_sender() = default;
constexpr explicit flow_many_sender(SF sf)
constexpr flow_sender() = default;
constexpr explicit flow_sender(SF sf)
: sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out)
......@@ -137,7 +137,7 @@ class flow_many_sender<SF> {
};
template <PUSHMI_TYPE_CONSTRAINT(FlowSender) Data, class DSF>
class flow_many_sender<Data, DSF> {
class flow_sender<Data, DSF> {
Data data_;
DSF sf_;
......@@ -149,10 +149,10 @@ class flow_many_sender<Data, DSF> {
FlowSender<Data>,
"Data must be a flow sender");
constexpr flow_many_sender() = default;
constexpr explicit flow_many_sender(Data data)
constexpr flow_sender() = default;
constexpr explicit flow_sender(Data data)
: data_(std::move(data)) {}
constexpr flow_many_sender(Data data, DSF sf)
constexpr flow_sender(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out)
......@@ -170,61 +170,61 @@ class flow_many_sender<Data, DSF> {
};
template <>
class flow_many_sender<>
: public flow_many_sender<ignoreSF> {
class flow_sender<>
: public flow_sender<ignoreSF> {
public:
flow_many_sender() = default;
flow_sender() = default;
};
////////////////////////////////////////////////////////////////////////////////
// make_flow_many_sender
// make_flow_sender
PUSHMI_INLINE_VAR constexpr struct make_flow_many_sender_fn {
inline auto operator()() const {
return flow_many_sender<ignoreSF>{};
return flow_sender<ignoreSF>{};
}
PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
auto operator()(SF sf) const {
return flow_many_sender<SF>{std::move(sf)};
return flow_sender<SF>{std::move(sf)};
}
PUSHMI_TEMPLATE(class Data)
(requires True<> && FlowSender<Data>)
auto operator()(Data d) const {
return flow_many_sender<Data, passDSF>{std::move(d)};
return flow_sender<Data, passDSF>{std::move(d)};
}
PUSHMI_TEMPLATE(class Data, class DSF)
(requires FlowSender<Data>)
auto operator()(Data d, DSF sf) const {
return flow_many_sender<Data, DSF>{std::move(d), std::move(sf)};
return flow_sender<Data, DSF>{std::move(d), std::move(sf)};
}
} const make_flow_many_sender {};
} const make_flow_sender {};
////////////////////////////////////////////////////////////////////////////////
// deduction guides
#if __cpp_deduction_guides >= 201703 && PUSHMI_NOT_ON_WINDOWS
flow_many_sender() -> flow_many_sender<ignoreSF>;
flow_sender() -> flow_sender<ignoreSF>;
PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
flow_many_sender(SF) -> flow_many_sender<SF>;
flow_sender(SF) -> flow_sender<SF>;
PUSHMI_TEMPLATE(class Data)
(requires True<> && FlowSender<Data>)
flow_many_sender(Data) -> flow_many_sender<Data, passDSF>;
flow_sender(Data) -> flow_sender<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF)
(requires FlowSender<Data>)
flow_many_sender(Data, DSF) -> flow_many_sender<Data, DSF>;
flow_sender(Data, DSF) -> flow_sender<Data, DSF>;
#endif
template<>
struct construct_deduced<flow_many_sender>
struct construct_deduced<flow_sender>
: make_flow_many_sender_fn {};
// // TODO constrain me
// template <class V, class E = std::exception_ptr, Sender Wrapped>
// auto erase_cast(Wrapped w) {
// return flow_many_sender<V, E>{std::move(w)};
// return flow_sender<V, E>{std::move(w)};
// }
} // namespace pushmi
......
......@@ -28,7 +28,7 @@ namespace folly {
namespace pushmi {
template <class E, class... VN>
class any_many_sender
class any_sender
: public sender_tag::with_values<VN...>::template with_error<E> {
using insitu_t = void*[2];
union data {
......@@ -49,7 +49,7 @@ class any_many_sender
static constexpr vtable const noop_{};
vtable const* vptr_ = &noop_;
template <class Wrapped>
any_many_sender(Wrapped obj, std::false_type) : any_many_sender() {
any_sender(Wrapped obj, std::false_type) : any_sender() {
struct s {
static void op(data& src, data* dst) {
if (dst)
......@@ -66,7 +66,7 @@ class any_many_sender
vptr_ = &vtbl;
}
template <class Wrapped>
any_many_sender(Wrapped obj, std::true_type) noexcept : any_many_sender() {
any_sender(Wrapped obj, std::true_type) noexcept : any_sender() {
struct s {
static void op(data& src, data* dst) {
if (dst)
......@@ -85,25 +85,25 @@ class any_many_sender
}
template <class T, class U = std::decay_t<T>>
using wrapped_t =
std::enable_if_t<!std::is_same<U, any_many_sender>::value, U>;
std::enable_if_t<!std::is_same<U, any_sender>::value, U>;
public:
any_many_sender() = default;
any_many_sender(any_many_sender&& that) noexcept : any_many_sender() {
any_sender() = default;
any_sender(any_sender&& that) noexcept : any_sender() {
that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_);
}
PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, any_receiver<E, VN...>>) //
explicit any_many_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_many_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_many_sender() {
explicit any_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_sender() {
vptr_->op_(data_, nullptr);
}
any_many_sender& operator=(any_many_sender&& that) noexcept {
this->~any_many_sender();
new ((void*)this) any_many_sender(std::move(that));
any_sender& operator=(any_sender&& that) noexcept {
this->~any_sender();
new ((void*)this) any_sender(std::move(that));
return *this;
}
PUSHMI_TEMPLATE(class Out)
......@@ -115,16 +115,16 @@ class any_many_sender
// Class static definitions:
template <class E, class... VN>
constexpr typename any_many_sender<E, VN...>::vtable const
any_many_sender<E, VN...>::noop_;
constexpr typename any_sender<E, VN...>::vtable const
any_sender<E, VN...>::noop_;
template <class SF>
class many_sender<SF> : public sender_tag {
class sender<SF> : public sender_tag {
SF sf_;
public:
constexpr many_sender() = default;
constexpr explicit many_sender(SF sf) : sf_(std::move(sf)) {}
constexpr sender() = default;
constexpr explicit sender(SF sf) : sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(
......@@ -135,7 +135,7 @@ class many_sender<SF> : public sender_tag {
};
template <PUSHMI_TYPE_CONSTRAINT(Sender) Data, class DSF>
class many_sender<Data, DSF> {
class sender<Data, DSF> {
Data data_;
DSF sf_;
......@@ -147,9 +147,9 @@ class many_sender<Data, DSF> {
Sender<Data>,
"Data must be a sender");
constexpr many_sender() = default;
constexpr explicit many_sender(Data data) : data_(std::move(data)) {}
constexpr many_sender(Data data, DSF sf)
constexpr sender() = default;
constexpr explicit sender(Data data) : data_(std::move(data)) {}
constexpr sender(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out)
......@@ -167,60 +167,60 @@ class many_sender<Data, DSF> {
};
template <>
class many_sender<> : public many_sender<ignoreSF> {
class sender<> : public sender<ignoreSF> {
public:
many_sender() = default;
sender() = default;
};
////////////////////////////////////////////////////////////////////////////////
// make_many_sender
// make_sender
PUSHMI_INLINE_VAR constexpr struct make_many_sender_fn {
inline auto operator()() const {
return many_sender<ignoreSF>{};
return sender<ignoreSF>{};
}
PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&&not Sender<SF>)) //
auto
operator()(SF sf) const {
return many_sender<SF>{std::move(sf)};
return sender<SF>{std::move(sf)};
}
PUSHMI_TEMPLATE(class Data)
(requires True<>&& Sender<Data>) //
auto
operator()(Data d) const {
return many_sender<Data, passDSF>{std::move(d)};
return sender<Data, passDSF>{std::move(d)};
}
PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data>) //
auto
operator()(Data d, DSF sf) const {
return many_sender<Data, DSF>{std::move(d), std::move(sf)};
return sender<Data, DSF>{std::move(d), std::move(sf)};
}
} const make_many_sender{};
} const make_sender{};
////////////////////////////////////////////////////////////////////////////////
// deduction guides
#if __cpp_deduction_guides >= 201703 && PUSHMI_NOT_ON_WINDOWS
many_sender()->many_sender<ignoreSF>;
sender()->sender<ignoreSF>;
PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&&not Sender<SF>)) //
many_sender(SF)
->many_sender<SF>;
sender(SF)
->sender<SF>;
PUSHMI_TEMPLATE(class Data)
(requires True<>&& Sender<Data>) //
many_sender(Data)
->many_sender<Data, passDSF>;
sender(Data)
->sender<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data>) //
many_sender(Data, DSF)
->many_sender<Data, DSF>;
sender(Data, DSF)
->sender<Data, DSF>;
#endif
template <>
struct construct_deduced<many_sender> : make_many_sender_fn {};
struct construct_deduced<sender> : make_many_sender_fn {};
} // namespace pushmi
} // namespace folly
......@@ -288,11 +288,11 @@ void single_sender_test() {
}
void many_sender_test() {
auto in0 = mi::MAKE(many_sender)();
auto in0 = mi::MAKE(sender)();
static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
auto in1 = mi::MAKE(many_sender)(mi::ignoreSF{});
auto in1 = mi::MAKE(sender)(mi::ignoreSF{});
static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
auto in2 = mi::MAKE(many_sender)(
auto in2 = mi::MAKE(sender)(
[&](auto out) {
in0.submit(mi::MAKE(receiver)(
std::move(out),
......@@ -305,7 +305,7 @@ void many_sender_test() {
out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
in2.submit(out1);
auto any0 = mi::any_many_sender<std::exception_ptr, int>(in0);
auto any0 = mi::any_sender<std::exception_ptr, int>(in0);
}
void flow_receiver_1_test() {
......@@ -477,13 +477,13 @@ void flow_single_sender_test() {
}
void flow_many_sender_test() {
auto in0 = mi::MAKE(flow_many_sender)();
auto in0 = mi::MAKE(flow_sender)();
static_assert(mi::Sender<decltype(in0)>, "in0 not a sender");
static_assert(mi::FlowSender<decltype(in0)>, "in0 not flow");
auto in1 = mi::MAKE(flow_many_sender)(mi::ignoreSF{});
auto in1 = mi::MAKE(flow_sender)(mi::ignoreSF{});
static_assert(mi::Sender<decltype(in1)>, "in1 not a sender");
static_assert(mi::FlowSender<decltype(in1)>, "in1 not flow");
auto in2 = mi::MAKE(flow_many_sender)(
auto in2 = mi::MAKE(flow_sender)(
[&](auto out) {
in0.submit(mi::MAKE(flow_receiver)(
std::move(out),
......@@ -497,7 +497,7 @@ void flow_many_sender_test() {
out0, mi::on_value([](auto d, int v) { mi::set_value(d, v); }));
in2.submit(out1);
auto any0 = mi::any_flow_many_sender<
auto any0 = mi::any_flow_sender<
std::exception_ptr,
std::ptrdiff_t,
std::exception_ptr,
......
......@@ -21,7 +21,7 @@
#include <chrono>
using namespace std::literals;
#include <folly/experimental/pushmi/sender/flow_many_sender.h>
#include <folly/experimental/pushmi/sender/flow_sender.h>
#include <folly/experimental/pushmi/o/for_each.h>
#include <folly/experimental/pushmi/o/from.h>
#include <folly/experimental/pushmi/o/submit.h>
......@@ -50,7 +50,7 @@ using namespace testing;
class ImmediateFlowManySender : public Test {
protected:
auto make_producer() {
return mi::MAKE(flow_many_sender)([&](auto out) {
return mi::MAKE(flow_sender)([&](auto out) {
using Out = decltype(out);
struct Data : mi::receiver<> {
explicit Data(Out out_) : out(std::move(out_)), stop(false) {}
......@@ -105,7 +105,7 @@ class ImmediateFlowManySender : public Test {
TEST(AnyFlowManySender, Construct) {
std::array<int, 3> arr{{0, 9, 99}};
auto m = folly::pushmi::operators::flow_from(arr);
auto any_m = folly::pushmi::any_flow_many_sender<
auto any_m = folly::pushmi::any_flow_sender<
std::exception_ptr,
std::ptrdiff_t,
std::exception_ptr,
......@@ -156,7 +156,7 @@ class ConcurrentFlowManySender : public Test {
}
void cancellation_test(std::chrono::system_clock::time_point at) {
auto f = mi::MAKE(flow_many_sender)([&](auto out) {
auto f = mi::MAKE(flow_sender)([&](auto out) {
using Out = decltype(out);
// boolean cancellation
......
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