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

rename deferred to sender

fbshipit-source-id: 4c647dd4716ae79e3727229d679680a30f4908cd
parent d76b6bf8
...@@ -157,121 +157,121 @@ auto s0 = single<int>{single{}}; ...@@ -157,121 +157,121 @@ auto s0 = single<int>{single{}};
auto s1 = single<int, std::exception_ptr>{single{}}; auto s1 = single<int, std::exception_ptr>{single{}};
``` ```
## `deferred` ## `sender`
The `deferred` type in the library provides simple ways to construct new implementations of the NoneSender concept. The `sender` type in the library provides simple ways to construct new implementations of the NoneSender concept.
construct a producer of nothing, aka `never()` construct a producer of nothing, aka `never()`
```cpp ```cpp
deferred<> d; sender<> d;
``` ```
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
```cpp ```cpp
auto d0 = deferred{on_submit{[](auto out){}}}; auto d0 = sender{on_submit{[](auto out){}}};
auto d1 = deferred{[](auto out){}}; auto d1 = sender{[](auto out){}};
auto d2 = deferred{on_submit{[](none<> out){}, [](auto out){}}}; auto d2 = sender{on_submit{[](none<> out){}, [](auto out){}}};
``` ```
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing deferred. The state must be a NoneSender, but can be a super-set with additional state for this filter. construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing sender. The state must be a NoneSender, but can be a super-set with additional state for this filter.
```cpp ```cpp
auto d0 = deferred{deferred{}}; auto d0 = sender{sender{}};
auto d1 = deferred{deferred{}, on_submit{ auto d1 = sender{sender{}, on_submit{
[](deferred<>& in, auto out){in | submit(out);}}}; [](sender<>& in, auto out){in | submit(out);}}};
auto d2 = deferred{deferred{}, auto d2 = sender{sender{},
[](deferred<>& in, auto out){in | submit(out);}}; [](sender<>& in, auto out){in | submit(out);}};
``` ```
construct a type-erased type for a particular E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors. construct a type-erased type for a particular E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.
```cpp ```cpp
auto d0 = deferred<>{deferred{}}; auto d0 = sender<>{sender{}};
auto d1 = deferred<std::exception_ptr>{deferred{}}; auto d1 = sender<std::exception_ptr>{sender{}};
``` ```
## `single_deferred` ## `single_sender`
The `single_deferred` type in the library provides simple ways to construct new implementations of the SingleSender concept. The `single_sender` type in the library provides simple ways to construct new implementations of the SingleSender concept.
construct a producer of nothing, aka `never()` construct a producer of nothing, aka `never()`
```cpp ```cpp
single_deferred<> sd; single_sender<> sd;
``` ```
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
```cpp ```cpp
auto sd0 = single_deferred{on_submit{[](auto out){}}}; auto sd0 = single_sender{on_submit{[](auto out){}}};
auto sd1 = single_deferred{[](auto out){}}; auto sd1 = single_sender{[](auto out){}};
auto sd2 = single_deferred{on_submit{[](single<> out){}, [](auto out){}}}; auto sd2 = single_sender{on_submit{[](single<> out){}, [](auto out){}}};
``` ```
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing single_deferred. The state must be a SingleSender, but can be a super-set with additional state for this filter. construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing single_sender. The state must be a SingleSender, but can be a super-set with additional state for this filter.
```cpp ```cpp
auto sd0 = single_deferred{single_deferred{}}; auto sd0 = single_sender{single_sender{}};
auto sd1 = single_deferred{single_deferred{}, on_submit{ auto sd1 = single_sender{single_sender{}, on_submit{
[](single_deferred<>& in, auto out){in | submit(out);}}}; [](single_sender<>& in, auto out){in | submit(out);}}};
auto sd2 = single_deferred{single_deferred{}, auto sd2 = single_sender{single_sender{},
[](single_deferred<>& in, auto out){in | submit(out);}}; [](single_sender<>& in, auto out){in | submit(out);}};
``` ```
construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors. construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.
```cpp ```cpp
auto sd0 = single_deferred<int>{single_deferred{}}; auto sd0 = single_sender<int>{single_sender{}};
auto sd1 = single_deferred<int, std::exception_ptr>{single_deferred{}}; auto sd1 = single_sender<int, std::exception_ptr>{single_sender{}};
``` ```
## `time_single_deferred` ## `time_single_sender`
The `time_single_deferred` type in the library provides simple ways to construct new implementations of the TimeSingleSender concept. The `time_single_sender` type in the library provides simple ways to construct new implementations of the TimeSingleSender concept.
construct a producer of nothing, aka `never()` construct a producer of nothing, aka `never()`
```cpp ```cpp
time_single_deferred<> tsd; time_single_sender<> tsd;
``` ```
construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets construct new type using one or more lambdas, or with designated initializers, use multiple lambdas to build overload sets
```cpp ```cpp
auto tsd0 = time_single_deferred{on_submit{[](auto at, auto out){}}}; auto tsd0 = time_single_sender{on_submit{[](auto at, auto out){}}};
auto tsd1 = time_single_deferred{[](auto at, auto out){}}; auto tsd1 = time_single_sender{[](auto at, auto out){}};
auto tsd2 = time_single_deferred{on_submit{[](auto at, single<> out){}, [](auto at, auto out){}}}; auto tsd2 = time_single_sender{on_submit{[](auto at, single<> out){}, [](auto at, auto out){}}};
``` ```
construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing time_single_deferred. The state must be a SingleSender, but can be a super-set with additional state for this filter. construct a new type with shared state across the lambdas. very useful for building a filter on top of an existing time_single_sender. The state must be a SingleSender, but can be a super-set with additional state for this filter.
```cpp ```cpp
auto tsd0 = time_single_deferred{single_deferred{}}; auto tsd0 = time_single_sender{single_sender{}};
auto tsd1 = time_single_deferred{single_deferred{}, on_submit{ auto tsd1 = time_single_sender{single_sender{}, on_submit{
[](time_single_deferred<>& in, auto at, auto out){in | submit(at, out);}}}; [](time_single_sender<>& in, auto at, auto out){in | submit(at, out);}}};
auto tsd2 = time_single_deferred{single_deferred{}, auto tsd2 = time_single_sender{single_sender{},
[](time_single_deferred<>& in, auto at, auto out){in | submit(at, out);}}; [](time_single_sender<>& in, auto at, auto out){in | submit(at, out);}};
``` ```
construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors. construct a type-erased type for a particular T & E (which could be a std::variant of supported types). I have a plan to provide operators to collapse values and errors to variant or tuple and then expand from variant or tuple back to their constituent values/errors.
```cpp ```cpp
auto tsd0 = time_single_deferred<int>{time_single_deferred{}}; auto tsd0 = time_single_sender<int>{time_single_sender{}};
auto tsd1 = time_single_deferred<int, std::exception_ptr>{time_single_deferred{}}; auto tsd1 = time_single_sender<int, std::exception_ptr>{time_single_sender{}};
``` ```
## put it all together with some algorithms ## put it all together with some algorithms
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "pushmi/none.h" #include "pushmi/none.h"
#include "pushmi/flow_single.h" #include "pushmi/flow_single.h"
#include "pushmi/flow_single_deferred.h" #include "pushmi/flow_single_sender.h"
#include "pushmi/entangle.h" #include "pushmi/entangle.h"
#include "pool.h" #include "pool.h"
......
...@@ -34,15 +34,15 @@ set(header_files ...@@ -34,15 +34,15 @@ set(header_files
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/boosters.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/boosters.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/piping.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/piping.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/none.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/none.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/deferred.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/sender.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/single.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/single.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/single_deferred.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/single_sender.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/time_single_deferred.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/time_single_sender.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/executor.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/executor.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/flow_single.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/flow_single.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/flow_single_deferred.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/flow_single_sender.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/many.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/many.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/many_deferred.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/many_sender.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/trampoline.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/trampoline.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/new_thread.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/new_thread.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/o/extension_operators.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/o/extension_operators.h"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include <pushmi/single_deferred.h> #include <pushmi/single_sender.h>
namespace pushmi { namespace pushmi {
...@@ -21,7 +21,7 @@ PUSHMI_INLINE_VAR constexpr struct bulk_fn { ...@@ -21,7 +21,7 @@ PUSHMI_INLINE_VAR constexpr struct bulk_fn {
IF&& initFunc, IF&& initFunc,
RS&& selector) const { RS&& selector) const {
return [func, sb, se, driver, initFunc, selector](auto in){ return [func, sb, se, driver, initFunc, selector](auto in){
return make_single_deferred( return make_single_sender(
[in, func, sb, se, driver, initFunc, selector](auto out) mutable { [in, func, sb, se, driver, initFunc, selector](auto out) mutable {
submit(in, make_single(std::move(out), submit(in, make_single(std::move(out),
[func, sb, se, driver, initFunc, selector](auto& out, auto input) { [func, sb, se, driver, initFunc, selector](auto& out, auto input) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include <pushmi/single_deferred.h> #include <pushmi/single_sender.h>
#include <pushmi/o/submit.h> #include <pushmi/o/submit.h>
namespace pushmi { namespace pushmi {
...@@ -33,7 +33,7 @@ private: ...@@ -33,7 +33,7 @@ private:
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>(out_impl<In>{}) ::pushmi::detail::submit_transform_out<In>(out_impl<In>{})
); );
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
inline auto executor() { inline auto executor() {
auto exec = execution::require(p.executor(), execution::never_blocking, execution::oneway); auto exec = execution::require(p.executor(), execution::never_blocking, execution::oneway);
return MAKE(time_single_deferred)(__pool_submit<decltype(exec)>{exec}); return MAKE(time_single_sender)(__pool_submit<decltype(exec)>{exec});
} }
inline void stop() {p.stop();} inline void stop() {p.stop();}
......
...@@ -14,7 +14,7 @@ using namespace pushmi::aliases; ...@@ -14,7 +14,7 @@ using namespace pushmi::aliases;
const bool setting_exists = false; const bool setting_exists = false;
auto get_setting() { auto get_setting() {
return mi::make_single_deferred( return mi::make_single_sender(
[](auto out){ [](auto out){
if(setting_exists) { if(setting_exists) {
op::just(42) | op::submit(out); op::just(42) | op::submit(out);
...@@ -31,7 +31,7 @@ auto println = [](auto v){std::cout << v << std::endl;}; ...@@ -31,7 +31,7 @@ auto println = [](auto v){std::cout << v << std::endl;};
template<class T, class E = std::exception_ptr> template<class T, class E = std::exception_ptr>
auto concat = auto concat =
[](auto in){ [](auto in){
return mi::make_single_deferred( return mi::make_single_sender(
[in](auto out) mutable { [in](auto out) mutable {
::pushmi::submit(in, mi::make_single(out, ::pushmi::submit(in, mi::make_single(out,
[](auto out, auto v){ [](auto out, auto v){
...@@ -54,9 +54,9 @@ int main() ...@@ -54,9 +54,9 @@ int main()
op::just(42) | op::just(42) |
op::transform([](int i) { op::transform([](int i) {
if (i < 42) { if (i < 42) {
return mi::any_single_deferred<std::string>{op::empty<std::string>()}; return mi::any_single_sender<std::string>{op::empty<std::string>()};
} }
return mi::any_single_deferred<std::string>{op::just(std::to_string(i))}; return mi::any_single_sender<std::string>{op::just(std::to_string(i))};
}) | }) |
concat<std::string> | concat<std::string> |
op::submit(println); op::submit(println);
......
...@@ -16,7 +16,7 @@ using namespace pushmi::aliases; ...@@ -16,7 +16,7 @@ using namespace pushmi::aliases;
template<class T, class E = std::exception_ptr> template<class T, class E = std::exception_ptr>
auto concat = auto concat =
[](auto in){ [](auto in){
return mi::make_single_deferred( return mi::make_single_sender(
[in](auto out) mutable { [in](auto out) mutable {
::pushmi::submit(in, mi::make_single(out, ::pushmi::submit(in, mi::make_single(out,
[](auto out, auto v){ [](auto out, auto v){
...@@ -63,7 +63,7 @@ int main() ...@@ -63,7 +63,7 @@ int main()
op::just(42) | op::just(42) |
op::transform([](auto v) { op::transform([](auto v) {
using r_t = mi::any_single_deferred<int>; using r_t = mi::any_single_sender<int>;
if (v < 40) { if (v < 40) {
return r_t{op::error<int>(std::exception_ptr{})}; return r_t{op::error<int>(std::exception_ptr{})};
} else { } else {
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <pool.h> #include <pool.h>
#include <pushmi/deferred.h> #include <pushmi/sender.h>
#include <pushmi/single_deferred.h> #include <pushmi/single_sender.h>
#include <pushmi/o/just.h> #include <pushmi/o/just.h>
#include <pushmi/o/via.h> #include <pushmi/o/via.h>
#include <pushmi/o/transform.h> #include <pushmi/o/transform.h>
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <pool.h> #include <pool.h>
#include <pushmi/deferred.h> #include <pushmi/sender.h>
#include <pushmi/single_deferred.h> #include <pushmi/single_sender.h>
#include <pushmi/o/transform.h> #include <pushmi/o/transform.h>
using namespace pushmi::aliases; using namespace pushmi::aliases;
......
This diff is collapsed.
...@@ -42,19 +42,19 @@ template<> ...@@ -42,19 +42,19 @@ template<>
struct construct_deduced<flow_single>; struct construct_deduced<flow_single>;
template<> template<>
struct construct_deduced<deferred>; struct construct_deduced<sender>;
template<> template<>
struct construct_deduced<single_deferred>; struct construct_deduced<single_sender>;
template<> template<>
struct construct_deduced<many_deferred>; struct construct_deduced<many_sender>;
template<> template<>
struct construct_deduced<flow_single_deferred>; struct construct_deduced<flow_single_sender>;
template<> template<>
struct construct_deduced<time_single_deferred>; struct construct_deduced<time_single_sender>;
template <template <class...> class T, class... AN> template <template <class...> class T, class... AN>
using deduced_type_t = pushmi::invoke_result_t<construct_deduced<T>, AN...>; using deduced_type_t = pushmi::invoke_result_t<construct_deduced<T>, AN...>;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include "time_single_deferred.h" #include "time_single_sender.h"
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
...@@ -113,7 +113,7 @@ any_time_executor_ref(Wrapped&) -> ...@@ -113,7 +113,7 @@ any_time_executor_ref(Wrapped&) ->
namespace detail { namespace detail {
template<class E, class TP> template<class E, class TP>
using any_time_executor_base = using any_time_executor_base =
any_time_single_deferred<any_time_executor_ref<E, TP>, E, TP>; any_time_single_sender<any_time_executor_ref<E, TP>, E, TP>;
template<class T, class E, class TP> template<class T, class E, class TP>
using not_any_time_executor = using not_any_time_executor =
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace pushmi { namespace pushmi {
template <class V, class PE, class E> template <class V, class PE, class E>
class flow_single_deferred<V, PE, E> { class flow_single_sender<V, PE, E> {
union data { union data {
void* pobj_ = nullptr; void* pobj_ = nullptr;
char buffer_[sizeof(V)]; // can hold a V in-situ char buffer_[sizeof(V)]; // can hold a V in-situ
...@@ -28,7 +28,7 @@ class flow_single_deferred<V, PE, E> { ...@@ -28,7 +28,7 @@ class flow_single_deferred<V, PE, E> {
static constexpr vtable const noop_ {}; static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_; vtable const* vptr_ = &noop_;
template <class Wrapped> template <class Wrapped>
flow_single_deferred(Wrapped obj, std::false_type) : flow_single_deferred() { flow_single_sender(Wrapped obj, std::false_type) : flow_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -44,8 +44,8 @@ class flow_single_deferred<V, PE, E> { ...@@ -44,8 +44,8 @@ class flow_single_deferred<V, PE, E> {
vptr_ = &vtbl; vptr_ = &vtbl;
} }
template <class Wrapped> template <class Wrapped>
flow_single_deferred(Wrapped obj, std::true_type) noexcept flow_single_sender(Wrapped obj, std::true_type) noexcept
: flow_single_deferred() { : flow_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -65,26 +65,26 @@ class flow_single_deferred<V, PE, E> { ...@@ -65,26 +65,26 @@ class flow_single_deferred<V, PE, E> {
} }
template <class T, class U = std::decay_t<T>> template <class T, class U = std::decay_t<T>>
using wrapped_t = using wrapped_t =
std::enable_if_t<!std::is_same<U, flow_single_deferred>::value, U>; std::enable_if_t<!std::is_same<U, flow_single_sender>::value, U>;
public: public:
using properties = property_set<is_sender<>, is_flow<>, is_single<>>; using properties = property_set<is_sender<>, is_flow<>, is_single<>>;
flow_single_deferred() = default; flow_single_sender() = default;
flow_single_deferred(flow_single_deferred&& that) noexcept flow_single_sender(flow_single_sender&& that) noexcept
: flow_single_deferred() { : flow_single_sender() {
that.vptr_->op_(that.data_, &data_); that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_); std::swap(that.vptr_, vptr_);
} }
PUSHMI_TEMPLATE (class Wrapped) PUSHMI_TEMPLATE (class Wrapped)
(requires FlowSender<wrapped_t<Wrapped>, is_single<>>) (requires FlowSender<wrapped_t<Wrapped>, is_single<>>)
explicit flow_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>()) explicit flow_single_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: flow_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : flow_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~flow_single_deferred() { ~flow_single_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
} }
flow_single_deferred& operator=(flow_single_deferred&& that) noexcept { flow_single_sender& operator=(flow_single_sender&& that) noexcept {
this->~flow_single_deferred(); this->~flow_single_sender();
new ((void*)this) flow_single_deferred(std::move(that)); new ((void*)this) flow_single_sender(std::move(that));
return *this; return *this;
} }
void submit(flow_single<V, PE, E> out) { void submit(flow_single<V, PE, E> out) {
...@@ -94,18 +94,18 @@ class flow_single_deferred<V, PE, E> { ...@@ -94,18 +94,18 @@ class flow_single_deferred<V, PE, E> {
// Class static definitions: // Class static definitions:
template <class V, class PE, class E> template <class V, class PE, class E>
constexpr typename flow_single_deferred<V, PE, E>::vtable const constexpr typename flow_single_sender<V, PE, E>::vtable const
flow_single_deferred<V, PE, E>::noop_; flow_single_sender<V, PE, E>::noop_;
template <class SF> template <class SF>
class flow_single_deferred<SF> { class flow_single_sender<SF> {
SF sf_; SF sf_;
public: public:
using properties = property_set<is_sender<>, is_flow<>, is_single<>>; using properties = property_set<is_sender<>, is_flow<>, is_single<>>;
constexpr flow_single_deferred() = default; constexpr flow_single_sender() = default;
constexpr explicit flow_single_deferred(SF sf) constexpr explicit flow_single_sender(SF sf)
: sf_(std::move(sf)) {} : sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
...@@ -116,17 +116,17 @@ class flow_single_deferred<SF> { ...@@ -116,17 +116,17 @@ class flow_single_deferred<SF> {
}; };
template <PUSHMI_TYPE_CONSTRAINT(Sender<is_single<>, is_flow<>>) Data, class DSF> template <PUSHMI_TYPE_CONSTRAINT(Sender<is_single<>, is_flow<>>) Data, class DSF>
class flow_single_deferred<Data, DSF> { class flow_single_sender<Data, DSF> {
Data data_; Data data_;
DSF sf_; DSF sf_;
public: public:
using properties = property_set<is_sender<>, is_single<>>; using properties = property_set<is_sender<>, is_single<>>;
constexpr flow_single_deferred() = default; constexpr flow_single_sender() = default;
constexpr explicit flow_single_deferred(Data data) constexpr explicit flow_single_sender(Data data)
: data_(std::move(data)) {} : data_(std::move(data)) {}
constexpr flow_single_deferred(Data data, DSF sf) constexpr flow_single_sender(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {} : data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(lazy::Receiver<Out, is_single<>, is_flow<>> PUSHMI_AND (requires PUSHMI_EXP(lazy::Receiver<Out, is_single<>, is_flow<>> PUSHMI_AND
...@@ -137,57 +137,57 @@ class flow_single_deferred<Data, DSF> { ...@@ -137,57 +137,57 @@ class flow_single_deferred<Data, DSF> {
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// make_flow_single_deferred // make_flow_single_sender
PUSHMI_INLINE_VAR constexpr struct make_flow_single_deferred_fn { PUSHMI_INLINE_VAR constexpr struct make_flow_single_sender_fn {
inline auto operator()() const { inline auto operator()() const {
return flow_single_deferred<ignoreSF>{}; return flow_single_sender<ignoreSF>{};
} }
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
auto operator()(SF sf) const { auto operator()(SF sf) const {
return flow_single_deferred<SF>{std::move(sf)}; return flow_single_sender<SF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_single<>, is_flow<>>) (requires True<> && Sender<Data, is_single<>, is_flow<>>)
auto operator()(Data d) const { auto operator()(Data d) const {
return flow_single_deferred<Data, passDSF>{std::move(d)}; return flow_single_sender<Data, passDSF>{std::move(d)};
} }
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_single<>, is_flow<>>) (requires Sender<Data, is_single<>, is_flow<>>)
auto operator()(Data d, DSF sf) const { auto operator()(Data d, DSF sf) const {
return flow_single_deferred<Data, DSF>{std::move(d), std::move(sf)}; return flow_single_sender<Data, DSF>{std::move(d), std::move(sf)};
} }
} const make_flow_single_deferred {}; } const make_flow_single_sender {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
flow_single_deferred() -> flow_single_deferred<ignoreSF>; flow_single_sender() -> flow_single_sender<ignoreSF>;
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
flow_single_deferred(SF) -> flow_single_deferred<SF>; flow_single_sender(SF) -> flow_single_sender<SF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_single<>, is_flow<>>) (requires True<> && Sender<Data, is_single<>, is_flow<>>)
flow_single_deferred(Data) -> flow_single_deferred<Data, passDSF>; flow_single_sender(Data) -> flow_single_sender<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_single<>, is_flow<>>) (requires Sender<Data, is_single<>, is_flow<>>)
flow_single_deferred(Data, DSF) -> flow_single_deferred<Data, DSF>; flow_single_sender(Data, DSF) -> flow_single_sender<Data, DSF>;
#endif #endif
template <class V, class PE = std::exception_ptr, class E = PE> template <class V, class PE = std::exception_ptr, class E = PE>
using any_flow_single_deferred = flow_single_deferred<V, PE, E>; using any_flow_single_sender = flow_single_sender<V, PE, E>;
template<> template<>
struct construct_deduced<flow_single_deferred> struct construct_deduced<flow_single_sender>
: make_flow_single_deferred_fn {}; : make_flow_single_sender_fn {};
// // TODO constrain me // // TODO constrain me
// template <class V, class E = std::exception_ptr, Sender Wrapped> // template <class V, class E = std::exception_ptr, Sender Wrapped>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return flow_single_deferred<V, E>{std::move(w)}; // return flow_single_sender<V, E>{std::move(w)};
// } // }
} // namespace pushmi } // namespace pushmi
...@@ -51,7 +51,7 @@ template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> ...@@ -51,7 +51,7 @@ template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class none; class none;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class deferred; class sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class single; class single;
...@@ -60,19 +60,19 @@ template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> ...@@ -60,19 +60,19 @@ template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class many; class many;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class single_deferred; class single_sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class many_deferred; class many_sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class time_single_deferred; class time_single_sender;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class flow_single; class flow_single;
template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN> template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
class flow_single_deferred; class flow_single_sender;
template< template<
class E = std::exception_ptr, class E = std::exception_ptr,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace pushmi { namespace pushmi {
template <class V, class E = std::exception_ptr> template <class V, class E = std::exception_ptr>
class any_many_deferred { class any_many_sender {
union data { union data {
void* pobj_ = nullptr; void* pobj_ = nullptr;
char buffer_[sizeof(V)]; // can hold a V in-situ char buffer_[sizeof(V)]; // can hold a V in-situ
...@@ -28,7 +28,7 @@ class any_many_deferred { ...@@ -28,7 +28,7 @@ class any_many_deferred {
static constexpr vtable const noop_ {}; static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_; vtable const* vptr_ = &noop_;
template <class Wrapped> template <class Wrapped>
any_many_deferred(Wrapped obj, std::false_type) : any_many_deferred() { any_many_sender(Wrapped obj, std::false_type) : any_many_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -44,8 +44,8 @@ class any_many_deferred { ...@@ -44,8 +44,8 @@ class any_many_deferred {
vptr_ = &vtbl; vptr_ = &vtbl;
} }
template <class Wrapped> template <class Wrapped>
any_many_deferred(Wrapped obj, std::true_type) noexcept any_many_sender(Wrapped obj, std::true_type) noexcept
: any_many_deferred() { : any_many_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -64,27 +64,27 @@ class any_many_deferred { ...@@ -64,27 +64,27 @@ class any_many_deferred {
} }
template <class T, class U = std::decay_t<T>> template <class T, class U = std::decay_t<T>>
using wrapped_t = using wrapped_t =
std::enable_if_t<!std::is_same<U, any_many_deferred>::value, U>; std::enable_if_t<!std::is_same<U, any_many_sender>::value, U>;
public: public:
using properties = property_set<is_sender<>, is_many<>>; using properties = property_set<is_sender<>, is_many<>>;
any_many_deferred() = default; any_many_sender() = default;
any_many_deferred(any_many_deferred&& that) noexcept any_many_sender(any_many_sender&& that) noexcept
: any_many_deferred() { : any_many_sender() {
that.vptr_->op_(that.data_, &data_); that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_); std::swap(that.vptr_, vptr_);
} }
PUSHMI_TEMPLATE(class Wrapped) PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, many<V, E>, is_many<>>) (requires SenderTo<wrapped_t<Wrapped>, many<V, E>, is_many<>>)
explicit any_many_deferred(Wrapped obj) noexcept(insitu<Wrapped>()) explicit any_many_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_many_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : any_many_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_many_deferred() { ~any_many_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
} }
any_many_deferred& operator=(any_many_deferred&& that) noexcept { any_many_sender& operator=(any_many_sender&& that) noexcept {
this->~any_many_deferred(); this->~any_many_sender();
new ((void*)this) any_many_deferred(std::move(that)); new ((void*)this) any_many_sender(std::move(that));
return *this; return *this;
} }
void submit(many<V, E> out) { void submit(many<V, E> out) {
...@@ -94,18 +94,18 @@ class any_many_deferred { ...@@ -94,18 +94,18 @@ class any_many_deferred {
// Class static definitions: // Class static definitions:
template <class V, class E> template <class V, class E>
constexpr typename any_many_deferred<V, E>::vtable const constexpr typename any_many_sender<V, E>::vtable const
any_many_deferred<V, E>::noop_; any_many_sender<V, E>::noop_;
template <class SF> template <class SF>
class many_deferred<SF> { class many_sender<SF> {
SF sf_; SF sf_;
public: public:
using properties = property_set<is_sender<>, is_many<>>; using properties = property_set<is_sender<>, is_many<>>;
constexpr many_deferred() = default; constexpr many_sender() = default;
constexpr explicit many_deferred(SF sf) constexpr explicit many_sender(SF sf)
: sf_(std::move(sf)) {} : sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
...@@ -117,17 +117,17 @@ class many_deferred<SF> { ...@@ -117,17 +117,17 @@ class many_deferred<SF> {
namespace detail { namespace detail {
template <PUSHMI_TYPE_CONSTRAINT(Sender<is_many<>>) Data, class DSF> template <PUSHMI_TYPE_CONSTRAINT(Sender<is_many<>>) Data, class DSF>
class many_deferred_2 { class many_sender_2 {
Data data_; Data data_;
DSF sf_; DSF sf_;
public: public:
using properties = property_set<is_sender<>, is_many<>>; using properties = property_set<is_sender<>, is_many<>>;
constexpr many_deferred_2() = default; constexpr many_sender_2() = default;
constexpr explicit many_deferred_2(Data data) constexpr explicit many_sender_2(Data data)
: data_(std::move(data)) {} : data_(std::move(data)) {}
constexpr many_deferred_2(Data data, DSF sf) constexpr many_sender_2(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {} : data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(lazy::Receiver<Out, is_many<>> PUSHMI_AND (requires PUSHMI_EXP(lazy::Receiver<Out, is_many<>> PUSHMI_AND
...@@ -138,70 +138,70 @@ class many_deferred_2 { ...@@ -138,70 +138,70 @@ class many_deferred_2 {
}; };
template <class A, class B> template <class A, class B>
using many_deferred_base = using many_sender_base =
std::conditional_t< std::conditional_t<
(bool)Sender<A, is_many<>>, (bool)Sender<A, is_many<>>,
many_deferred_2<A, B>, many_sender_2<A, B>,
any_many_deferred<A, B>>; any_many_sender<A, B>>;
} // namespace detail } // namespace detail
template <class A, class B> template <class A, class B>
struct many_deferred<A, B> struct many_sender<A, B>
: detail::many_deferred_base<A, B> { : detail::many_sender_base<A, B> {
constexpr many_deferred() = default; constexpr many_sender() = default;
using detail::many_deferred_base<A, B>::many_deferred_base; using detail::many_sender_base<A, B>::many_sender_base;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// make_many_deferred // make_many_sender
PUSHMI_INLINE_VAR constexpr struct make_many_deferred_fn { PUSHMI_INLINE_VAR constexpr struct make_many_sender_fn {
inline auto operator()() const { inline auto operator()() const {
return many_deferred<ignoreSF>{}; return many_sender<ignoreSF>{};
} }
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
auto operator()(SF sf) const { auto operator()(SF sf) const {
return many_deferred<SF>{std::move(sf)}; return many_sender<SF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_many<>>) (requires True<> && Sender<Data, is_many<>>)
auto operator()(Data d) const { auto operator()(Data d) const {
return many_deferred<Data, passDSF>{std::move(d)}; return many_sender<Data, passDSF>{std::move(d)};
} }
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_many<>>) (requires Sender<Data, is_many<>>)
auto operator()(Data d, DSF sf) const { auto operator()(Data d, DSF sf) const {
return many_deferred<Data, DSF>{std::move(d), std::move(sf)}; return many_sender<Data, DSF>{std::move(d), std::move(sf)};
} }
} const make_many_deferred {}; } const make_many_sender {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
many_deferred() -> many_deferred<ignoreSF>; many_sender() -> many_sender<ignoreSF>;
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
many_deferred(SF) -> many_deferred<SF>; many_sender(SF) -> many_sender<SF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_many<>>) (requires True<> && Sender<Data, is_many<>>)
many_deferred(Data) -> many_deferred<Data, passDSF>; many_sender(Data) -> many_sender<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_many<>>) (requires Sender<Data, is_many<>>)
many_deferred(Data, DSF) -> many_deferred<Data, DSF>; many_sender(Data, DSF) -> many_sender<Data, DSF>;
#endif #endif
template<> template<>
struct construct_deduced<many_deferred> : make_many_deferred_fn {}; struct construct_deduced<many_sender> : make_many_sender_fn {};
// template < // template <
// class V, // class V,
// class E = std::exception_ptr, // class E = std::exception_ptr,
// SenderTo<many<V, E>, is_many<>> Wrapped> // SenderTo<many<V, E>, is_many<>> Wrapped>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return many_deferred<V, E>{std::move(w)}; // return many_sender<V, E>{std::move(w)};
// } // }
} // namespace pushmi } // namespace pushmi
...@@ -26,7 +26,7 @@ struct __new_thread_submit { ...@@ -26,7 +26,7 @@ struct __new_thread_submit {
}; };
inline auto new_thread() { inline auto new_thread() {
return make_time_single_deferred(__new_thread_submit{}); return make_time_single_sender(__new_thread_submit{});
} }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include "../single.h" #include "../single.h"
#include "../single_deferred.h" #include "../single_sender.h"
#include "submit.h" #include "submit.h"
#include "extension_operators.h" #include "extension_operators.h"
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
PUSHMI_TEMPLATE(class F) PUSHMI_TEMPLATE(class F)
(requires Invocable<F&>) (requires Invocable<F&>)
auto operator()(F f) const { auto operator()(F f) const {
return make_single_deferred(impl<F>{std::move(f)}); return make_single_sender(impl<F>{std::move(f)});
} }
} defer {}; } defer {};
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include "../deferred.h" #include "../sender.h"
#include "../single_deferred.h" #include "../single_sender.h"
#include "../detail/functional.h" #include "../detail/functional.h"
namespace pushmi { namespace pushmi {
...@@ -32,11 +32,11 @@ namespace detail { ...@@ -32,11 +32,11 @@ namespace detail {
namespace operators { namespace operators {
template <class V> template <class V>
auto empty() { auto empty() {
return make_single_deferred(detail::single_empty_impl<V>{}); return make_single_sender(detail::single_empty_impl<V>{});
} }
inline auto empty() { inline auto empty() {
return make_deferred(detail::empty_impl{}); return make_sender(detail::empty_impl{});
} }
} // namespace operators } // namespace operators
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include "../deferred.h" #include "../sender.h"
#include "submit.h" #include "submit.h"
#include "extension_operators.h" #include "extension_operators.h"
...@@ -37,13 +37,13 @@ namespace operators { ...@@ -37,13 +37,13 @@ namespace operators {
PUSHMI_TEMPLATE(class E) PUSHMI_TEMPLATE(class E)
(requires SemiMovable<E>) (requires SemiMovable<E>)
auto error(E e) { auto error(E e) {
return make_deferred(detail::error_impl<E>{std::move(e)}); return make_sender(detail::error_impl<E>{std::move(e)});
} }
PUSHMI_TEMPLATE(class V, class E) PUSHMI_TEMPLATE(class V, class E)
(requires SemiMovable<V> && SemiMovable<E>) (requires SemiMovable<V> && SemiMovable<E>)
auto error(E e) { auto error(E e) {
return make_single_deferred(detail::single_error_impl<V, E>{std::move(e)}); return make_single_sender(detail::single_error_impl<V, E>{std::move(e)});
} }
} // namespace operators } // namespace operators
......
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
#include "../piping.h" #include "../piping.h"
#include "../boosters.h" #include "../boosters.h"
#include "../single.h" #include "../single.h"
#include "../deferred.h" #include "../sender.h"
#include "../single_deferred.h" #include "../single_sender.h"
#include "../many.h" #include "../many.h"
#include "../many_deferred.h" #include "../many_sender.h"
#include "../time_single_deferred.h" #include "../time_single_sender.h"
#include "../flow_single.h" #include "../flow_single.h"
#include "../flow_single_deferred.h" #include "../flow_single_sender.h"
#include "../detail/if_constexpr.h" #include "../detail/if_constexpr.h"
#include "../detail/functional.h" #include "../detail/functional.h"
...@@ -154,17 +154,17 @@ auto submit_transform_out(SDSF, TSDSF tsdsf) { ...@@ -154,17 +154,17 @@ auto submit_transform_out(SDSF, TSDSF tsdsf) {
template <class Cardinality, bool IsTime = false, bool IsFlow = false> template <class Cardinality, bool IsTime = false, bool IsFlow = false>
struct make_sender; struct make_sender;
template <> template <>
struct make_sender<is_none<>> : construct_deduced<deferred> {}; struct make_sender<is_none<>> : construct_deduced<sender> {};
template <> template <>
struct make_sender<is_single<>> : construct_deduced<single_deferred> {}; struct make_sender<is_single<>> : construct_deduced<single_sender> {};
template <> template <>
struct make_sender<is_many<>> : construct_deduced<many_deferred> {}; struct make_sender<is_many<>> : construct_deduced<many_sender> {};
template <> template <>
struct make_sender<is_single<>, false, true> : construct_deduced<flow_single_deferred> {}; struct make_sender<is_single<>, false, true> : construct_deduced<flow_single_sender> {};
template <> template <>
struct make_sender<is_single<>, true, false> : construct_deduced<time_single_deferred> {}; struct make_sender<is_single<>, true, false> : construct_deduced<time_single_sender> {};
PUSHMI_INLINE_VAR constexpr struct deferred_from_fn { PUSHMI_INLINE_VAR constexpr struct sender_from_fn {
PUSHMI_TEMPLATE(class In, class... FN) PUSHMI_TEMPLATE(class In, class... FN)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in, FN&&... fn) const { auto operator()(In in, FN&&... fn) const {
...@@ -175,7 +175,7 @@ PUSHMI_INLINE_VAR constexpr struct deferred_from_fn { ...@@ -175,7 +175,7 @@ PUSHMI_INLINE_VAR constexpr struct deferred_from_fn {
property_query_v<properties_t<In>, is_flow<>>>; property_query_v<properties_t<In>, is_flow<>>>;
return MakeSender{}(std::move(in), (FN&&) fn...); return MakeSender{}(std::move(in), (FN&&) fn...);
} }
} const deferred_from {}; } const sender_from {};
PUSHMI_TEMPLATE( PUSHMI_TEMPLATE(
class In, class In,
...@@ -184,7 +184,7 @@ PUSHMI_TEMPLATE( ...@@ -184,7 +184,7 @@ PUSHMI_TEMPLATE(
bool SingleSenderRequires, bool SingleSenderRequires,
bool TimeSingleSenderRequires) bool TimeSingleSenderRequires)
(requires Sender<In> && Receiver<Out>) (requires Sender<In> && Receiver<Out>)
constexpr bool deferred_requires_from() { constexpr bool sender_requires_from() {
PUSHMI_IF_CONSTEXPR_RETURN( ((bool) TimeSenderTo<In, Out, is_single<>>) ( PUSHMI_IF_CONSTEXPR_RETURN( ((bool) TimeSenderTo<In, Out, is_single<>>) (
return TimeSingleSenderRequires; return TimeSingleSenderRequires;
) else ( ) else (
......
...@@ -44,7 +44,7 @@ private: ...@@ -44,7 +44,7 @@ private:
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>(out_impl<In, Predicate>{p_}) ::pushmi::detail::submit_transform_out<In>(out_impl<In, Predicate>{p_})
); );
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include "../many_deferred.h" #include "../many_sender.h"
#include "extension_operators.h" #include "extension_operators.h"
#include "submit.h" #include "submit.h"
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
typename std::iterator_traits<I>::iterator_category, typename std::iterator_traits<I>::iterator_category,
std::forward_iterator_tag>) std::forward_iterator_tag>)
auto operator()(I begin, S end) const { auto operator()(I begin, S end) const {
return make_many_deferred(out_impl<I, S>{begin, end}); return make_many_sender(out_impl<I, S>{begin, end});
} }
PUSHMI_TEMPLATE(class R) PUSHMI_TEMPLATE(class R)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// This source code is licensed under the MIT license found in the // This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include "../single_deferred.h" #include "../single_sender.h"
#include "submit.h" #include "submit.h"
#include "extension_operators.h" #include "extension_operators.h"
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
PUSHMI_TEMPLATE(class V) PUSHMI_TEMPLATE(class V)
(requires SemiMovable<V>) (requires SemiMovable<V>)
auto operator()(V v) const { auto operator()(V v) const {
return make_single_deferred(impl<V>{std::move(v)}); return make_single_sender(impl<V>{std::move(v)});
} }
} just {}; } just {};
} // namespace operators } // namespace operators
......
...@@ -63,7 +63,7 @@ private: ...@@ -63,7 +63,7 @@ private:
PUSHMI_TEMPLATE (class In) PUSHMI_TEMPLATE (class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
detail::submit_transform_out<In>( detail::submit_transform_out<In>(
out_impl<In, ExecutorFactory>{ef_}, out_impl<In, ExecutorFactory>{ef_},
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// LICENSE file in the root directory of this source tree. // LICENSE file in the root directory of this source tree.
#include <functional> #include <functional>
#include "../time_single_deferred.h" #include "../time_single_sender.h"
#include "../boosters.h" #include "../boosters.h"
#include "extension_operators.h" #include "extension_operators.h"
#include "../trampoline.h" #include "../trampoline.h"
......
...@@ -43,7 +43,7 @@ private: ...@@ -43,7 +43,7 @@ private:
PUSHMI_TEMPLATE (class In) PUSHMI_TEMPLATE (class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::pushmi::detail::submit_transform_out<In>(
out_impl<In, ErrorSelector>{es_} out_impl<In, ErrorSelector>{es_}
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include <cassert> #include <cassert>
#include "extension_operators.h" #include "extension_operators.h"
#include "../deferred.h" #include "../sender.h"
#include "../single_deferred.h" #include "../single_sender.h"
#include "../time_single_deferred.h" #include "../time_single_sender.h"
namespace pushmi { namespace pushmi {
...@@ -72,13 +72,13 @@ private: ...@@ -72,13 +72,13 @@ private:
template <class In, class SideEffects> template <class In, class SideEffects>
static auto impl(In in, SideEffects sideEffects) { static auto impl(In in, SideEffects sideEffects) {
PUSHMI_STATIC_ASSERT( PUSHMI_STATIC_ASSERT(
::pushmi::detail::deferred_requires_from<In, SideEffects, ::pushmi::detail::sender_requires_from<In, SideEffects,
SenderTo<In, SideEffects, is_none<>>, SenderTo<In, SideEffects, is_none<>>,
SenderTo<In, SideEffects, is_single<>>, SenderTo<In, SideEffects, is_single<>>,
TimeSenderTo<In, SideEffects, is_single<>> >(), TimeSenderTo<In, SideEffects, is_single<>> >(),
"'In' is not deliverable to 'SideEffects'"); "'In' is not deliverable to 'SideEffects'");
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::pushmi::detail::submit_transform_out<In>(
out_impl<In, SideEffects>{std::move(sideEffects)} out_impl<In, SideEffects>{std::move(sideEffects)}
...@@ -104,7 +104,7 @@ private: ...@@ -104,7 +104,7 @@ private:
(requires Receiver<Out>) (requires Receiver<Out>)
auto operator()(Out out) const { auto operator()(Out out) const {
PUSHMI_STATIC_ASSERT( PUSHMI_STATIC_ASSERT(
::pushmi::detail::deferred_requires_from<In, SideEffects, ::pushmi::detail::sender_requires_from<In, SideEffects,
SenderTo<In, Out, is_none<>>, SenderTo<In, Out, is_none<>>,
SenderTo<In, Out, is_single<>>, SenderTo<In, Out, is_single<>>,
TimeSenderTo<In, Out, is_single<>> >(), TimeSenderTo<In, Out, is_single<>> >(),
...@@ -113,7 +113,7 @@ private: ...@@ -113,7 +113,7 @@ private:
detail::make_tap(sideEffects_, std::move(out)))}; detail::make_tap(sideEffects_, std::move(out)))};
using Gang = decltype(gang); using Gang = decltype(gang);
PUSHMI_STATIC_ASSERT( PUSHMI_STATIC_ASSERT(
::pushmi::detail::deferred_requires_from<In, SideEffects, ::pushmi::detail::sender_requires_from<In, SideEffects,
SenderTo<In, Gang>, SenderTo<In, Gang>,
SenderTo<In, Gang, is_single<>>, SenderTo<In, Gang, is_single<>>,
TimeSenderTo<In, Gang, is_single<>> >(), TimeSenderTo<In, Gang, is_single<>> >(),
......
...@@ -69,7 +69,7 @@ private: ...@@ -69,7 +69,7 @@ private:
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
using Cardinality = property_set_index_t<properties_t<In>, is_silent<>>; using Cardinality = property_set_index_t<properties_t<In>, is_silent<>>;
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::pushmi::detail::submit_transform_out<In>(
// copy 'f_' to allow multiple calls to connect to multiple 'in' // copy 'f_' to allow multiple calls to connect to multiple 'in'
......
...@@ -109,7 +109,7 @@ private: ...@@ -109,7 +109,7 @@ private:
PUSHMI_TEMPLATE (class In) PUSHMI_TEMPLATE (class In)
(requires Sender<In>) (requires Sender<In>)
auto operator()(In in) const { auto operator()(In in) const {
return ::pushmi::detail::deferred_from( return ::pushmi::detail::sender_from(
std::move(in), std::move(in),
::pushmi::detail::submit_transform_out<In>( ::pushmi::detail::submit_transform_out<In>(
out_impl<In, ExecutorFactory>{ef_} out_impl<In, ExecutorFactory>{ef_}
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
namespace pushmi { namespace pushmi {
namespace detail { namespace detail {
struct erase_deferred_t {}; struct erase_sender_t {};
} // namespace detail } // namespace detail
template <class E> template <class E>
class deferred<detail::erase_deferred_t, E> { class sender<detail::erase_sender_t, E> {
union data { union data {
void* pobj_ = nullptr; void* pobj_ = nullptr;
char buffer_[sizeof(std::promise<void>)]; // can hold a void promise in-situ char buffer_[sizeof(std::promise<void>)]; // can hold a void promise in-situ
...@@ -31,7 +31,7 @@ class deferred<detail::erase_deferred_t, E> { ...@@ -31,7 +31,7 @@ class deferred<detail::erase_deferred_t, E> {
static constexpr vtable const noop_ {}; static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_; vtable const* vptr_ = &noop_;
template <class Wrapped> template <class Wrapped>
deferred(Wrapped obj, std::false_type) : deferred() { sender(Wrapped obj, std::false_type) : sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -47,7 +47,7 @@ class deferred<detail::erase_deferred_t, E> { ...@@ -47,7 +47,7 @@ class deferred<detail::erase_deferred_t, E> {
vptr_ = &vtbl; vptr_ = &vtbl;
} }
template <class Wrapped> template <class Wrapped>
deferred(Wrapped obj, std::true_type) noexcept : deferred() { sender(Wrapped obj, std::true_type) noexcept : sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -66,25 +66,25 @@ class deferred<detail::erase_deferred_t, E> { ...@@ -66,25 +66,25 @@ class deferred<detail::erase_deferred_t, E> {
} }
template <class T, class U = std::decay_t<T>> template <class T, class U = std::decay_t<T>>
using wrapped_t = using wrapped_t =
std::enable_if_t<!std::is_same<U, deferred>::value, U>; std::enable_if_t<!std::is_same<U, sender>::value, U>;
public: public:
using properties = property_set<is_sender<>, is_none<>>; using properties = property_set<is_sender<>, is_none<>>;
deferred() = default; sender() = default;
deferred(deferred&& that) noexcept : deferred() { sender(sender&& that) noexcept : sender() {
that.vptr_->op_(that.data_, &data_); that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_); std::swap(that.vptr_, vptr_);
} }
PUSHMI_TEMPLATE(class Wrapped) PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, any_none<E>, is_none<>>) (requires SenderTo<wrapped_t<Wrapped>, any_none<E>, is_none<>>)
explicit deferred(Wrapped obj) noexcept(insitu<Wrapped>()) explicit sender(Wrapped obj) noexcept(insitu<Wrapped>())
: deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~deferred() { ~sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
} }
deferred& operator=(deferred&& that) noexcept { sender& operator=(sender&& that) noexcept {
this->~deferred(); this->~sender();
new ((void*)this) deferred(std::move(that)); new ((void*)this) sender(std::move(that));
return *this; return *this;
} }
void submit(any_none<E> out) { void submit(any_none<E> out) {
...@@ -94,18 +94,18 @@ class deferred<detail::erase_deferred_t, E> { ...@@ -94,18 +94,18 @@ class deferred<detail::erase_deferred_t, E> {
// Class static definitions: // Class static definitions:
template <class E> template <class E>
constexpr typename deferred<detail::erase_deferred_t, E>::vtable const constexpr typename sender<detail::erase_sender_t, E>::vtable const
deferred<detail::erase_deferred_t, E>::noop_; sender<detail::erase_sender_t, E>::noop_;
template <class SF> template <class SF>
class deferred<SF> { class sender<SF> {
SF sf_; SF sf_;
public: public:
using properties = property_set<is_sender<>, is_none<>>; using properties = property_set<is_sender<>, is_none<>>;
constexpr deferred() = default; constexpr sender() = default;
constexpr explicit deferred(SF sf) : sf_(std::move(sf)) {} constexpr explicit sender(SF sf) : sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out, is_none<>> && Invocable<SF&, Out>) (requires Receiver<Out, is_none<>> && Invocable<SF&, Out>)
void submit(Out out) { void submit(Out out) {
...@@ -114,7 +114,7 @@ class deferred<SF> { ...@@ -114,7 +114,7 @@ class deferred<SF> {
}; };
template <PUSHMI_TYPE_CONSTRAINT(Sender<is_none<>>) Data, class DSF> template <PUSHMI_TYPE_CONSTRAINT(Sender<is_none<>>) Data, class DSF>
class deferred<Data, DSF> { class sender<Data, DSF> {
Data data_; Data data_;
DSF sf_; DSF sf_;
static_assert(Sender<Data, is_none<>>, "The Data template parameter " static_assert(Sender<Data, is_none<>>, "The Data template parameter "
...@@ -123,10 +123,10 @@ class deferred<Data, DSF> { ...@@ -123,10 +123,10 @@ class deferred<Data, DSF> {
public: public:
using properties = property_set<is_sender<>, is_none<>>; using properties = property_set<is_sender<>, is_none<>>;
constexpr deferred() = default; constexpr sender() = default;
constexpr explicit deferred(Data data) constexpr explicit sender(Data data)
: data_(std::move(data)) {} : data_(std::move(data)) {}
constexpr deferred(Data data, DSF sf) constexpr sender(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {} : data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
...@@ -137,60 +137,60 @@ class deferred<Data, DSF> { ...@@ -137,60 +137,60 @@ class deferred<Data, DSF> {
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// make_deferred // make_sender
PUSHMI_INLINE_VAR constexpr struct make_deferred_fn { PUSHMI_INLINE_VAR constexpr struct make_sender_fn {
inline auto operator()() const { inline auto operator()() const {
return deferred<ignoreSF>{}; return sender<ignoreSF>{};
} }
template <class SF> template <class SF>
auto operator()(SF sf) const { auto operator()(SF sf) const {
return deferred<SF>{std::move(sf)}; return sender<SF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class Wrapped) PUSHMI_TEMPLATE(class Wrapped)
(requires Sender<Wrapped, is_none<>>) (requires Sender<Wrapped, is_none<>>)
auto operator()(Wrapped w) const { auto operator()(Wrapped w) const {
return deferred<detail::erase_deferred_t, std::exception_ptr>{std::move(w)}; return sender<detail::erase_sender_t, std::exception_ptr>{std::move(w)};
} }
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_none<>>) (requires Sender<Data, is_none<>>)
auto operator()(Data data, DSF sf) const { auto operator()(Data data, DSF sf) const {
return deferred<Data, DSF>{std::move(data), std::move(sf)}; return sender<Data, DSF>{std::move(data), std::move(sf)};
} }
} const make_deferred {}; } const make_sender {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
deferred() -> deferred<ignoreSF>; sender() -> sender<ignoreSF>;
template <class SF> template <class SF>
deferred(SF) -> deferred<SF>; sender(SF) -> sender<SF>;
PUSHMI_TEMPLATE(class Wrapped) PUSHMI_TEMPLATE(class Wrapped)
(requires Sender<Wrapped, is_none<>>) (requires Sender<Wrapped, is_none<>>)
deferred(Wrapped) -> sender(Wrapped) ->
deferred<detail::erase_deferred_t, std::exception_ptr>; sender<detail::erase_sender_t, std::exception_ptr>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_none<>>) (requires Sender<Data, is_none<>>)
deferred(Data, DSF) -> deferred<Data, DSF>; sender(Data, DSF) -> sender<Data, DSF>;
#endif #endif
template <class E = std::exception_ptr> template <class E = std::exception_ptr>
using any_deferred = deferred<detail::erase_deferred_t, E>; using any_sender = sender<detail::erase_sender_t, E>;
template<> template<>
struct construct_deduced<deferred> : make_deferred_fn {}; struct construct_deduced<sender> : make_sender_fn {};
// template <SenderTo<any_none<std::exception_ptr>, is_none<>> Wrapped> // template <SenderTo<any_none<std::exception_ptr>, is_none<>> Wrapped>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return deferred<detail::erase_deferred_t, std::exception_ptr>{std::move(w)}; // return sender<detail::erase_sender_t, std::exception_ptr>{std::move(w)};
// } // }
// //
// template <class E, SenderTo<any_none<E>, is_none<>> Wrapped> // template <class E, SenderTo<any_none<E>, is_none<>> Wrapped>
// requires Same<is_none<>, properties_t<Wrapped>> // requires Same<is_none<>, properties_t<Wrapped>>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return deferred<detail::erase_deferred_t, E>{std::move(w)}; // return sender<detail::erase_sender_t, E>{std::move(w)};
// } // }
} // namespace pushmi } // namespace pushmi
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace pushmi { namespace pushmi {
template <class V, class E = std::exception_ptr> template <class V, class E = std::exception_ptr>
class any_single_deferred { class any_single_sender {
union data { union data {
void* pobj_ = nullptr; void* pobj_ = nullptr;
char buffer_[sizeof(V)]; // can hold a V in-situ char buffer_[sizeof(V)]; // can hold a V in-situ
...@@ -28,7 +28,7 @@ class any_single_deferred { ...@@ -28,7 +28,7 @@ class any_single_deferred {
static constexpr vtable const noop_ {}; static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_; vtable const* vptr_ = &noop_;
template <class Wrapped> template <class Wrapped>
any_single_deferred(Wrapped obj, std::false_type) : any_single_deferred() { any_single_sender(Wrapped obj, std::false_type) : any_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -44,8 +44,8 @@ class any_single_deferred { ...@@ -44,8 +44,8 @@ class any_single_deferred {
vptr_ = &vtbl; vptr_ = &vtbl;
} }
template <class Wrapped> template <class Wrapped>
any_single_deferred(Wrapped obj, std::true_type) noexcept any_single_sender(Wrapped obj, std::true_type) noexcept
: any_single_deferred() { : any_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -64,27 +64,27 @@ class any_single_deferred { ...@@ -64,27 +64,27 @@ class any_single_deferred {
} }
template <class T, class U = std::decay_t<T>> template <class T, class U = std::decay_t<T>>
using wrapped_t = using wrapped_t =
std::enable_if_t<!std::is_same<U, any_single_deferred>::value, U>; std::enable_if_t<!std::is_same<U, any_single_sender>::value, U>;
public: public:
using properties = property_set<is_sender<>, is_single<>>; using properties = property_set<is_sender<>, is_single<>>;
any_single_deferred() = default; any_single_sender() = default;
any_single_deferred(any_single_deferred&& that) noexcept any_single_sender(any_single_sender&& that) noexcept
: any_single_deferred() { : any_single_sender() {
that.vptr_->op_(that.data_, &data_); that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_); std::swap(that.vptr_, vptr_);
} }
PUSHMI_TEMPLATE(class Wrapped) PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, single<V, E>, is_single<>>) (requires SenderTo<wrapped_t<Wrapped>, single<V, E>, is_single<>>)
explicit any_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>()) explicit any_single_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : any_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_single_deferred() { ~any_single_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
} }
any_single_deferred& operator=(any_single_deferred&& that) noexcept { any_single_sender& operator=(any_single_sender&& that) noexcept {
this->~any_single_deferred(); this->~any_single_sender();
new ((void*)this) any_single_deferred(std::move(that)); new ((void*)this) any_single_sender(std::move(that));
return *this; return *this;
} }
void submit(single<V, E> out) { void submit(single<V, E> out) {
...@@ -94,18 +94,18 @@ class any_single_deferred { ...@@ -94,18 +94,18 @@ class any_single_deferred {
// Class static definitions: // Class static definitions:
template <class V, class E> template <class V, class E>
constexpr typename any_single_deferred<V, E>::vtable const constexpr typename any_single_sender<V, E>::vtable const
any_single_deferred<V, E>::noop_; any_single_sender<V, E>::noop_;
template <class SF> template <class SF>
class single_deferred<SF> { class single_sender<SF> {
SF sf_; SF sf_;
public: public:
using properties = property_set<is_sender<>, is_single<>>; using properties = property_set<is_sender<>, is_single<>>;
constexpr single_deferred() = default; constexpr single_sender() = default;
constexpr explicit single_deferred(SF sf) constexpr explicit single_sender(SF sf)
: sf_(std::move(sf)) {} : sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
...@@ -117,17 +117,17 @@ class single_deferred<SF> { ...@@ -117,17 +117,17 @@ class single_deferred<SF> {
namespace detail { namespace detail {
template <PUSHMI_TYPE_CONSTRAINT(Sender<is_single<>>) Data, class DSF> template <PUSHMI_TYPE_CONSTRAINT(Sender<is_single<>>) Data, class DSF>
class single_deferred_2 { class single_sender_2 {
Data data_; Data data_;
DSF sf_; DSF sf_;
public: public:
using properties = property_set<is_sender<>, is_single<>>; using properties = property_set<is_sender<>, is_single<>>;
constexpr single_deferred_2() = default; constexpr single_sender_2() = default;
constexpr explicit single_deferred_2(Data data) constexpr explicit single_sender_2(Data data)
: data_(std::move(data)) {} : data_(std::move(data)) {}
constexpr single_deferred_2(Data data, DSF sf) constexpr single_sender_2(Data data, DSF sf)
: data_(std::move(data)), sf_(std::move(sf)) {} : data_(std::move(data)), sf_(std::move(sf)) {}
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(lazy::Receiver<Out, is_single<>> PUSHMI_AND (requires PUSHMI_EXP(lazy::Receiver<Out, is_single<>> PUSHMI_AND
...@@ -138,70 +138,70 @@ class single_deferred_2 { ...@@ -138,70 +138,70 @@ class single_deferred_2 {
}; };
template <class A, class B> template <class A, class B>
using single_deferred_base = using single_sender_base =
std::conditional_t< std::conditional_t<
(bool)Sender<A, is_single<>>, (bool)Sender<A, is_single<>>,
single_deferred_2<A, B>, single_sender_2<A, B>,
any_single_deferred<A, B>>; any_single_sender<A, B>>;
} // namespace detail } // namespace detail
template <class A, class B> template <class A, class B>
struct single_deferred<A, B> struct single_sender<A, B>
: detail::single_deferred_base<A, B> { : detail::single_sender_base<A, B> {
constexpr single_deferred() = default; constexpr single_sender() = default;
using detail::single_deferred_base<A, B>::single_deferred_base; using detail::single_sender_base<A, B>::single_sender_base;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// make_single_deferred // make_single_sender
PUSHMI_INLINE_VAR constexpr struct make_single_deferred_fn { PUSHMI_INLINE_VAR constexpr struct make_single_sender_fn {
inline auto operator()() const { inline auto operator()() const {
return single_deferred<ignoreSF>{}; return single_sender<ignoreSF>{};
} }
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
auto operator()(SF sf) const { auto operator()(SF sf) const {
return single_deferred<SF>{std::move(sf)}; return single_sender<SF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_single<>>) (requires True<> && Sender<Data, is_single<>>)
auto operator()(Data d) const { auto operator()(Data d) const {
return single_deferred<Data, passDSF>{std::move(d)}; return single_sender<Data, passDSF>{std::move(d)};
} }
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_single<>>) (requires Sender<Data, is_single<>>)
auto operator()(Data d, DSF sf) const { auto operator()(Data d, DSF sf) const {
return single_deferred<Data, DSF>{std::move(d), std::move(sf)}; return single_sender<Data, DSF>{std::move(d), std::move(sf)};
} }
} const make_single_deferred {}; } const make_single_sender {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
single_deferred() -> single_deferred<ignoreSF>; single_sender() -> single_sender<ignoreSF>;
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
single_deferred(SF) -> single_deferred<SF>; single_sender(SF) -> single_sender<SF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_single<>>) (requires True<> && Sender<Data, is_single<>>)
single_deferred(Data) -> single_deferred<Data, passDSF>; single_sender(Data) -> single_sender<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_single<>>) (requires Sender<Data, is_single<>>)
single_deferred(Data, DSF) -> single_deferred<Data, DSF>; single_sender(Data, DSF) -> single_sender<Data, DSF>;
#endif #endif
template<> template<>
struct construct_deduced<single_deferred> : make_single_deferred_fn {}; struct construct_deduced<single_sender> : make_single_sender_fn {};
// template < // template <
// class V, // class V,
// class E = std::exception_ptr, // class E = std::exception_ptr,
// SenderTo<single<V, E>, is_single<>> Wrapped> // SenderTo<single<V, E>, is_single<>> Wrapped>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return single_deferred<V, E>{std::move(w)}; // return single_sender<V, E>{std::move(w)};
// } // }
} // namespace pushmi } // namespace pushmi
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <vector> #include <vector>
#include <pushmi/time_single_deferred.h> #include <pushmi/time_single_sender.h>
namespace pushmi { namespace pushmi {
...@@ -58,7 +58,7 @@ struct subject<T, PS> { ...@@ -58,7 +58,7 @@ struct subject<T, PS> {
} }
}; };
// need a template overload of none/deferred and the rest that stores a 'ptr' with its own lifetime management // need a template overload of none/sender and the rest that stores a 'ptr' with its own lifetime management
struct subject_receiver { struct subject_receiver {
using properties = property_set_insert_t<property_set<is_receiver<>, is_single<>>, PS>; using properties = property_set_insert_t<property_set<is_receiver<>, is_single<>>, PS>;
......
...@@ -12,7 +12,7 @@ template < ...@@ -12,7 +12,7 @@ template <
class V, class V,
class E = std::exception_ptr, class E = std::exception_ptr,
class TP = std::chrono::system_clock::time_point> class TP = std::chrono::system_clock::time_point>
class any_time_single_deferred { class any_time_single_sender {
union data { union data {
void* pobj_ = nullptr; void* pobj_ = nullptr;
char buffer_[sizeof(std::promise<int>)]; // can hold a V in-situ char buffer_[sizeof(std::promise<int>)]; // can hold a V in-situ
...@@ -33,8 +33,8 @@ class any_time_single_deferred { ...@@ -33,8 +33,8 @@ class any_time_single_deferred {
static constexpr vtable const noop_ {}; static constexpr vtable const noop_ {};
vtable const* vptr_ = &noop_; vtable const* vptr_ = &noop_;
template <class Wrapped> template <class Wrapped>
any_time_single_deferred(Wrapped obj, std::false_type) any_time_single_sender(Wrapped obj, std::false_type)
: any_time_single_deferred() { : any_time_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -56,8 +56,8 @@ class any_time_single_deferred { ...@@ -56,8 +56,8 @@ class any_time_single_deferred {
vptr_ = &vtbl; vptr_ = &vtbl;
} }
template <class Wrapped> template <class Wrapped>
any_time_single_deferred(Wrapped obj, std::true_type) noexcept any_time_single_sender(Wrapped obj, std::true_type) noexcept
: any_time_single_deferred() { : any_time_single_sender() {
struct s { struct s {
static void op(data& src, data* dst) { static void op(data& src, data* dst) {
if (dst) if (dst)
...@@ -81,28 +81,28 @@ class any_time_single_deferred { ...@@ -81,28 +81,28 @@ class any_time_single_deferred {
} }
template <class T, class U = std::decay_t<T>> template <class T, class U = std::decay_t<T>>
using wrapped_t = using wrapped_t =
std::enable_if_t<!std::is_same<U, any_time_single_deferred>::value, U>; std::enable_if_t<!std::is_same<U, any_time_single_sender>::value, U>;
public: public:
using properties = property_set<is_time<>, is_single<>>; using properties = property_set<is_time<>, is_single<>>;
any_time_single_deferred() = default; any_time_single_sender() = default;
any_time_single_deferred(any_time_single_deferred&& that) noexcept any_time_single_sender(any_time_single_sender&& that) noexcept
: any_time_single_deferred() { : any_time_single_sender() {
that.vptr_->op_(that.data_, &data_); that.vptr_->op_(that.data_, &data_);
std::swap(that.vptr_, vptr_); std::swap(that.vptr_, vptr_);
} }
PUSHMI_TEMPLATE (class Wrapped) PUSHMI_TEMPLATE (class Wrapped)
(requires TimeSenderTo<wrapped_t<Wrapped>, single<V, E>>) (requires TimeSenderTo<wrapped_t<Wrapped>, single<V, E>>)
explicit any_time_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>()) explicit any_time_single_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_time_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} { : any_time_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {
} }
~any_time_single_deferred() { ~any_time_single_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
} }
any_time_single_deferred& operator=(any_time_single_deferred&& that) noexcept { any_time_single_sender& operator=(any_time_single_sender&& that) noexcept {
this->~any_time_single_deferred(); this->~any_time_single_sender();
new ((void*)this) any_time_single_deferred(std::move(that)); new ((void*)this) any_time_single_sender(std::move(that));
return *this; return *this;
} }
TP now() { TP now() {
...@@ -115,24 +115,24 @@ class any_time_single_deferred { ...@@ -115,24 +115,24 @@ class any_time_single_deferred {
// Class static definitions: // Class static definitions:
template <class V, class E, class TP> template <class V, class E, class TP>
constexpr typename any_time_single_deferred<V, E, TP>::vtable const constexpr typename any_time_single_sender<V, E, TP>::vtable const
any_time_single_deferred<V, E, TP>::noop_; any_time_single_sender<V, E, TP>::noop_;
template <class SF, class NF> template <class SF, class NF>
#if __cpp_concepts #if __cpp_concepts
requires Invocable<NF&> requires Invocable<NF&>
#endif #endif
class time_single_deferred<SF, NF> { class time_single_sender<SF, NF> {
SF sf_; SF sf_;
NF nf_; NF nf_;
public: public:
using properties = property_set<is_time<>, is_single<>>; using properties = property_set<is_time<>, is_single<>>;
constexpr time_single_deferred() = default; constexpr time_single_sender() = default;
constexpr explicit time_single_deferred(SF sf) constexpr explicit time_single_sender(SF sf)
: sf_(std::move(sf)) {} : sf_(std::move(sf)) {}
constexpr time_single_deferred(SF sf, NF nf) constexpr time_single_sender(SF sf, NF nf)
: sf_(std::move(sf)), nf_(std::move(nf)) {} : sf_(std::move(sf)), nf_(std::move(nf)) {}
auto now() { auto now() {
return nf_(); return nf_();
...@@ -150,7 +150,7 @@ template <PUSHMI_TYPE_CONSTRAINT(TimeSender<is_single<>>) Data, class DSF, class ...@@ -150,7 +150,7 @@ template <PUSHMI_TYPE_CONSTRAINT(TimeSender<is_single<>>) Data, class DSF, class
#if __cpp_concepts #if __cpp_concepts
requires Invocable<DNF&, Data&> requires Invocable<DNF&, Data&>
#endif #endif
class time_single_deferred_2 { class time_single_sender_2 {
Data data_; Data data_;
DSF sf_; DSF sf_;
DNF nf_; DNF nf_;
...@@ -158,10 +158,10 @@ class time_single_deferred_2 { ...@@ -158,10 +158,10 @@ class time_single_deferred_2 {
public: public:
using properties = property_set<is_time<>, is_single<>>; using properties = property_set<is_time<>, is_single<>>;
constexpr time_single_deferred_2() = default; constexpr time_single_sender_2() = default;
constexpr explicit time_single_deferred_2(Data data) constexpr explicit time_single_sender_2(Data data)
: data_(std::move(data)) {} : data_(std::move(data)) {}
constexpr time_single_deferred_2(Data data, DSF sf, DNF nf = DNF{}) constexpr time_single_sender_2(Data data, DSF sf, DNF nf = DNF{})
: data_(std::move(data)), sf_(std::move(sf)), nf_(std::move(nf)) {} : data_(std::move(data)), sf_(std::move(sf)), nf_(std::move(nf)) {}
auto now() { auto now() {
return nf_(data_); return nf_(data_);
...@@ -175,72 +175,72 @@ class time_single_deferred_2 { ...@@ -175,72 +175,72 @@ class time_single_deferred_2 {
}; };
template <class A, class B, class C> template <class A, class B, class C>
using time_single_deferred_base = using time_single_sender_base =
std::conditional_t< std::conditional_t<
(bool)TimeSender<A, is_single<>>, (bool)TimeSender<A, is_single<>>,
time_single_deferred_2<A, B, C>, time_single_sender_2<A, B, C>,
any_time_single_deferred<A, B, C>>; any_time_single_sender<A, B, C>>;
} // namespace detail } // namespace detail
template <class A, class B, class C> template <class A, class B, class C>
struct time_single_deferred<A, B, C> struct time_single_sender<A, B, C>
: detail::time_single_deferred_base<A, B, C> { : detail::time_single_sender_base<A, B, C> {
constexpr time_single_deferred() = default; constexpr time_single_sender() = default;
using detail::time_single_deferred_base<A, B, C>::time_single_deferred_base; using detail::time_single_sender_base<A, B, C>::time_single_sender_base;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// make_time_single_deferred // make_time_single_sender
PUSHMI_INLINE_VAR constexpr struct make_time_single_deferred_fn { PUSHMI_INLINE_VAR constexpr struct make_time_single_sender_fn {
inline auto operator()() const { inline auto operator()() const {
return time_single_deferred<ignoreSF, systemNowF>{}; return time_single_sender<ignoreSF, systemNowF>{};
} }
template <class SF> template <class SF>
auto operator()(SF sf) const { auto operator()(SF sf) const {
return time_single_deferred<SF, systemNowF>{std::move(sf)}; return time_single_sender<SF, systemNowF>{std::move(sf)};
} }
PUSHMI_TEMPLATE (class SF, class NF) PUSHMI_TEMPLATE (class SF, class NF)
(requires Invocable<NF&>) (requires Invocable<NF&>)
auto operator()(SF sf, NF nf) const { auto operator()(SF sf, NF nf) const {
return time_single_deferred<SF, NF>{std::move(sf), std::move(nf)}; return time_single_sender<SF, NF>{std::move(sf), std::move(nf)};
} }
PUSHMI_TEMPLATE (class Data, class DSF) PUSHMI_TEMPLATE (class Data, class DSF)
(requires TimeSender<Data, is_single<>>) (requires TimeSender<Data, is_single<>>)
auto operator()(Data d, DSF sf) const { auto operator()(Data d, DSF sf) const {
return time_single_deferred<Data, DSF, passDNF>{std::move(d), std::move(sf)}; return time_single_sender<Data, DSF, passDNF>{std::move(d), std::move(sf)};
} }
PUSHMI_TEMPLATE (class Data, class DSF, class DNF) PUSHMI_TEMPLATE (class Data, class DSF, class DNF)
(requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&>) (requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&>)
auto operator()(Data d, DSF sf, DNF nf) const { auto operator()(Data d, DSF sf, DNF nf) const {
return time_single_deferred<Data, DSF, DNF>{std::move(d), std::move(sf), return time_single_sender<Data, DSF, DNF>{std::move(d), std::move(sf),
std::move(nf)}; std::move(nf)};
} }
} const make_time_single_deferred {}; } const make_time_single_sender {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
time_single_deferred() -> time_single_deferred<ignoreSF, systemNowF>; time_single_sender() -> time_single_sender<ignoreSF, systemNowF>;
template <class SF> template <class SF>
time_single_deferred(SF) -> time_single_deferred<SF, systemNowF>; time_single_sender(SF) -> time_single_sender<SF, systemNowF>;
PUSHMI_TEMPLATE (class SF, class NF) PUSHMI_TEMPLATE (class SF, class NF)
(requires Invocable<NF&>) (requires Invocable<NF&>)
time_single_deferred(SF, NF) -> time_single_deferred<SF, NF>; time_single_sender(SF, NF) -> time_single_sender<SF, NF>;
PUSHMI_TEMPLATE (class Data, class DSF) PUSHMI_TEMPLATE (class Data, class DSF)
(requires TimeSender<Data, is_single<>>) (requires TimeSender<Data, is_single<>>)
time_single_deferred(Data, DSF) -> time_single_deferred<Data, DSF, passDNF>; time_single_sender(Data, DSF) -> time_single_sender<Data, DSF, passDNF>;
PUSHMI_TEMPLATE (class Data, class DSF, class DNF) PUSHMI_TEMPLATE (class Data, class DSF, class DNF)
(requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&>) (requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&>)
time_single_deferred(Data, DSF, DNF) -> time_single_deferred<Data, DSF, DNF>; time_single_sender(Data, DSF, DNF) -> time_single_sender<Data, DSF, DNF>;
#endif #endif
template<> template<>
struct construct_deduced<time_single_deferred> struct construct_deduced<time_single_sender>
: make_time_single_deferred_fn {}; : make_time_single_sender_fn {};
// template < // template <
// class V, // class V,
...@@ -248,7 +248,7 @@ struct construct_deduced<time_single_deferred> ...@@ -248,7 +248,7 @@ struct construct_deduced<time_single_deferred>
// class TP = std::chrono::system_clock::time_point, // class TP = std::chrono::system_clock::time_point,
// TimeSenderTo<single<V, E>, is_single<>> Wrapped> // TimeSenderTo<single<V, E>, is_single<>> Wrapped>
// auto erase_cast(Wrapped w) { // auto erase_cast(Wrapped w) {
// return time_single_deferred<V, E>{std::move(w)}; // return time_single_sender<V, E>{std::move(w)};
// } // }
} // namespace pushmi } // namespace pushmi
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <deque> #include <deque>
#include <thread> #include <thread>
#include "executor.h" #include "executor.h"
#include "time_single_deferred.h" #include "time_single_sender.h"
namespace pushmi { namespace pushmi {
......
...@@ -55,10 +55,10 @@ void none_test() { ...@@ -55,10 +55,10 @@ void none_test() {
auto any3 = pushmi::any_none<>(proxy0); auto any3 = pushmi::any_none<>(proxy0);
} }
void deferred_test(){ void sender_test(){
auto in0 = pushmi::MAKE(deferred)(); auto in0 = pushmi::MAKE(sender)();
auto in1 = pushmi::MAKE(deferred)(pushmi::ignoreSF{}); auto in1 = pushmi::MAKE(sender)(pushmi::ignoreSF{});
auto in3 = pushmi::MAKE(deferred)([&](auto out){ auto in3 = pushmi::MAKE(sender)([&](auto out){
in0.submit(pushmi::MAKE(none)(std::move(out), [](auto d, auto e) noexcept { in0.submit(pushmi::MAKE(none)(std::move(out), [](auto d, auto e) noexcept {
pushmi::set_error(d, e); pushmi::set_error(d, e);
})); }));
...@@ -74,7 +74,7 @@ void deferred_test(){ ...@@ -74,7 +74,7 @@ void deferred_test(){
out1.error(std::exception_ptr{}); out1.error(std::exception_ptr{});
in3.submit(out1); in3.submit(out1);
auto any0 = pushmi::any_deferred<>(in0); auto any0 = pushmi::any_sender<>(in0);
} }
void single_test() { void single_test() {
...@@ -189,10 +189,10 @@ void many_test() { ...@@ -189,10 +189,10 @@ void many_test() {
auto any1 = pushmi::any_many<int>(proxy0); auto any1 = pushmi::any_many<int>(proxy0);
} }
void single_deferred_test(){ void single_sender_test(){
auto in0 = pushmi::MAKE(single_deferred)(); auto in0 = pushmi::MAKE(single_sender)();
auto in1 = pushmi::MAKE(single_deferred)(pushmi::ignoreSF{}); auto in1 = pushmi::MAKE(single_sender)(pushmi::ignoreSF{});
auto in3 = pushmi::MAKE(single_deferred)([&](auto out){ auto in3 = pushmi::MAKE(single_sender)([&](auto out){
in0.submit(pushmi::MAKE(single)(std::move(out), in0.submit(pushmi::MAKE(single)(std::move(out),
pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); }) pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); })
)); ));
...@@ -208,13 +208,13 @@ void single_deferred_test(){ ...@@ -208,13 +208,13 @@ void single_deferred_test(){
})); }));
in3.submit(out1); in3.submit(out1);
auto any0 = pushmi::any_single_deferred<int>(in0); auto any0 = pushmi::any_single_sender<int>(in0);
} }
void many_deferred_test(){ void many_sender_test(){
auto in0 = pushmi::MAKE(many_deferred)(); auto in0 = pushmi::MAKE(many_sender)();
auto in1 = pushmi::MAKE(many_deferred)(pushmi::ignoreSF{}); auto in1 = pushmi::MAKE(many_sender)(pushmi::ignoreSF{});
auto in3 = pushmi::MAKE(many_deferred)([&](auto out){ auto in3 = pushmi::MAKE(many_sender)([&](auto out){
in0.submit(pushmi::MAKE(many)(std::move(out), in0.submit(pushmi::MAKE(many)(std::move(out),
pushmi::on_next([](auto d, int v){ pushmi::set_next(d, v); }) pushmi::on_next([](auto d, int v){ pushmi::set_next(d, v); })
)); ));
...@@ -226,18 +226,18 @@ void many_deferred_test(){ ...@@ -226,18 +226,18 @@ void many_deferred_test(){
})); }));
in3.submit(out1); in3.submit(out1);
auto any0 = pushmi::any_many_deferred<int>(in0); auto any0 = pushmi::any_many_sender<int>(in0);
} }
void time_single_deferred_test(){ void time_single_sender_test(){
auto in0 = pushmi::MAKE(time_single_deferred)(); auto in0 = pushmi::MAKE(time_single_sender)();
auto in1 = pushmi::MAKE(time_single_deferred)(pushmi::ignoreSF{}); auto in1 = pushmi::MAKE(time_single_sender)(pushmi::ignoreSF{});
auto in3 = pushmi::MAKE(time_single_deferred)([&](auto tp, auto out){ auto in3 = pushmi::MAKE(time_single_sender)([&](auto tp, auto out){
in0.submit(tp, pushmi::MAKE(single)(std::move(out), in0.submit(tp, pushmi::MAKE(single)(std::move(out),
pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); }) pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); })
)); ));
}); });
auto in4 = pushmi::MAKE(time_single_deferred)(pushmi::ignoreSF{}, pushmi::systemNowF{}); auto in4 = pushmi::MAKE(time_single_sender)(pushmi::ignoreSF{}, pushmi::systemNowF{});
std::promise<int> p0; std::promise<int> p0;
auto promise0 = pushmi::MAKE(single)(std::move(p0)); auto promise0 = pushmi::MAKE(single)(std::move(p0));
...@@ -249,7 +249,7 @@ void time_single_deferred_test(){ ...@@ -249,7 +249,7 @@ void time_single_deferred_test(){
})); }));
in3.submit(in0.now(), out1); in3.submit(in0.now(), out1);
auto any0 = pushmi::any_time_single_deferred<int>(in0); auto any0 = pushmi::any_time_single_sender<int>(in0);
in3 | op::submit(); in3 | op::submit();
in3 | op::submit_at(in3.now() + 1s); in3 | op::submit_at(in3.now() + 1s);
...@@ -365,10 +365,10 @@ void flow_single_test() { ...@@ -365,10 +365,10 @@ void flow_single_test() {
auto any3 = pushmi::any_flow_single<int>(proxy0); auto any3 = pushmi::any_flow_single<int>(proxy0);
} }
void flow_single_deferred_test(){ void flow_single_sender_test(){
auto in0 = pushmi::MAKE(flow_single_deferred)(); auto in0 = pushmi::MAKE(flow_single_sender)();
auto in1 = pushmi::MAKE(flow_single_deferred)(pushmi::ignoreSF{}); auto in1 = pushmi::MAKE(flow_single_sender)(pushmi::ignoreSF{});
auto in3 = pushmi::MAKE(flow_single_deferred)([&](auto out){ auto in3 = pushmi::MAKE(flow_single_sender)([&](auto out){
in0.submit(pushmi::MAKE(flow_single)(std::move(out), in0.submit(pushmi::MAKE(flow_single)(std::move(out),
pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); }) pushmi::on_value([](auto d, int v){ pushmi::set_value(d, v); })
)); ));
...@@ -380,5 +380,5 @@ void flow_single_deferred_test(){ ...@@ -380,5 +380,5 @@ void flow_single_deferred_test(){
})); }));
in3.submit(out1); in3.submit(out1);
auto any0 = pushmi::any_flow_single_deferred<int>(in0); auto any0 = pushmi::any_flow_single_sender<int>(in0);
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
using namespace std::literals; using namespace std::literals;
#include "pushmi/flow_single_deferred.h" #include "pushmi/flow_single_sender.h"
#include "pushmi/o/submit.h" #include "pushmi/o/submit.h"
#include "pushmi/entangle.h" #include "pushmi/entangle.h"
...@@ -22,11 +22,11 @@ using namespace pushmi::aliases; ...@@ -22,11 +22,11 @@ using namespace pushmi::aliases;
#define MAKE(x) make_##x #define MAKE(x) make_##x
#endif #endif
SCENARIO("flow single immediate cancellation", "[flow][deferred]") { SCENARIO("flow single immediate cancellation", "[flow][sender]") {
int signals = 0; int signals = 0;
GIVEN("A flow single deferred") { GIVEN("A flow single sender") {
auto f = mi::MAKE(flow_single_deferred)([&](auto out) { auto f = mi::MAKE(flow_single_sender)([&](auto out) {
// boolean cancellation // boolean cancellation
bool stop = false; bool stop = false;
auto set_stop = [](auto& stop) { auto set_stop = [](auto& stop) {
...@@ -102,13 +102,13 @@ SCENARIO("flow single immediate cancellation", "[flow][deferred]") { ...@@ -102,13 +102,13 @@ SCENARIO("flow single immediate cancellation", "[flow][deferred]") {
} }
} }
SCENARIO("flow single cancellation trampoline", "[flow][deferred]") { SCENARIO("flow single cancellation trampoline", "[flow][sender]") {
auto tr = mi::trampoline(); auto tr = mi::trampoline();
using TR = decltype(tr); using TR = decltype(tr);
int signals = 0; int signals = 0;
GIVEN("A flow single deferred") { GIVEN("A flow single sender") {
auto f = mi::MAKE(flow_single_deferred)([&](auto out) { auto f = mi::MAKE(flow_single_sender)([&](auto out) {
// boolean cancellation // boolean cancellation
bool stop = false; bool stop = false;
auto set_stop = [](auto& stop) { auto set_stop = [](auto& stop) {
...@@ -213,14 +213,14 @@ struct moving_atomic : std::atomic<T> { ...@@ -213,14 +213,14 @@ struct moving_atomic : std::atomic<T> {
moving_atomic(moving_atomic&& o) : std::atomic<T>(o.load()) {} moving_atomic(moving_atomic&& o) : std::atomic<T>(o.load()) {}
}; };
SCENARIO("flow single shared cancellation new thread", "[flow][deferred]") { SCENARIO("flow single shared cancellation new thread", "[flow][sender]") {
auto nt = mi::new_thread(); auto nt = mi::new_thread();
using NT = decltype(nt); using NT = decltype(nt);
std::atomic<int> signals{0}; std::atomic<int> signals{0};
auto at = nt.now() + 200ms; auto at = nt.now() + 200ms;
GIVEN("A flow single deferred") { GIVEN("A flow single sender") {
auto f = mi::MAKE(flow_single_deferred)([&](auto out) { auto f = mi::MAKE(flow_single_sender)([&](auto out) {
// boolean cancellation // boolean cancellation
bool stop = false; bool stop = false;
auto set_stop = [](auto& stop) { auto set_stop = [](auto& stop) {
...@@ -383,14 +383,14 @@ SCENARIO("flow single shared cancellation new thread", "[flow][deferred]") { ...@@ -383,14 +383,14 @@ SCENARIO("flow single shared cancellation new thread", "[flow][deferred]") {
} }
} }
SCENARIO("flow single entangled cancellation new thread", "[flow][deferred]") { SCENARIO("flow single entangled cancellation new thread", "[flow][sender]") {
auto nt = mi::new_thread(); auto nt = mi::new_thread();
using NT = decltype(nt); using NT = decltype(nt);
std::atomic<int> signals{0}; std::atomic<int> signals{0};
auto at = nt.now() + 200ms; auto at = nt.now() + 200ms;
GIVEN("A flow single deferred") { GIVEN("A flow single sender") {
auto f = mi::MAKE(flow_single_deferred)([&](auto out) { auto f = mi::MAKE(flow_single_sender)([&](auto out) {
// boolean cancellation // boolean cancellation
bool stop = false; bool stop = false;
auto set_stop = [](auto& stop) { auto set_stop = [](auto& stop) {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
using namespace std::literals; using namespace std::literals;
#include "pushmi/flow_single_deferred.h" #include "pushmi/flow_single_sender.h"
#include "pushmi/o/empty.h" #include "pushmi/o/empty.h"
#include "pushmi/o/just.h" #include "pushmi/o/just.h"
#include "pushmi/o/on.h" #include "pushmi/o/on.h"
...@@ -34,9 +34,9 @@ struct countdownsingle { ...@@ -34,9 +34,9 @@ struct countdownsingle {
} }
}; };
SCENARIO( "new_thread executor", "[new_thread][deferred]" ) { SCENARIO( "new_thread executor", "[new_thread][sender]" ) {
GIVEN( "A new_thread time_single_deferred" ) { GIVEN( "A new_thread time_single_sender" ) {
auto nt = v::new_thread(); auto nt = v::new_thread();
using NT = decltype(nt); using NT = decltype(nt);
...@@ -140,14 +140,14 @@ SCENARIO( "new_thread executor", "[new_thread][deferred]" ) { ...@@ -140,14 +140,14 @@ SCENARIO( "new_thread executor", "[new_thread][deferred]" ) {
WHEN( "used with on" ) { WHEN( "used with on" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto deferred = pushmi::make_single_deferred([](auto out) { auto sender = pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::pushmi::set_value(out, 2.0);
// ignored // ignored
::pushmi::set_value(out, 1); ::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
deferred | op::on([&](){return nt;}) | sender | op::on([&](){return nt;}) |
op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
THEN( "only the first item was pushed" ) { THEN( "only the first item was pushed" ) {
REQUIRE(values == std::vector<std::string>{"2.000000"}); REQUIRE(values == std::vector<std::string>{"2.000000"});
...@@ -156,14 +156,14 @@ SCENARIO( "new_thread executor", "[new_thread][deferred]" ) { ...@@ -156,14 +156,14 @@ SCENARIO( "new_thread executor", "[new_thread][deferred]" ) {
WHEN( "used with via" ) { WHEN( "used with via" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto deferred = pushmi::make_single_deferred([](auto out) { auto sender = pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::pushmi::set_value(out, 2.0);
// ignored // ignored
::pushmi::set_value(out, 1); ::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
deferred | op::via([&](){return nt;}) | sender | op::via([&](){return nt;}) |
op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::blocking_submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
THEN( "only the first item was pushed" ) { THEN( "only the first item was pushed" ) {
REQUIRE(values == std::vector<std::string>{"2.000000"}); REQUIRE(values == std::vector<std::string>{"2.000000"});
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
using namespace std::literals; using namespace std::literals;
#include "pushmi/flow_single_deferred.h" #include "pushmi/flow_single_sender.h"
#include "pushmi/o/empty.h" #include "pushmi/o/empty.h"
#include "pushmi/o/from.h" #include "pushmi/o/from.h"
#include "pushmi/o/just.h" #include "pushmi/o/just.h"
...@@ -22,9 +22,9 @@ using namespace std::literals; ...@@ -22,9 +22,9 @@ using namespace std::literals;
using namespace pushmi::aliases; using namespace pushmi::aliases;
SCENARIO( "empty can be used with tap and submit", "[empty][deferred]" ) { SCENARIO( "empty can be used with tap and submit", "[empty][sender]" ) {
GIVEN( "An empty deferred" ) { GIVEN( "An empty sender" ) {
auto e = op::empty(); auto e = op::empty();
using E = decltype(e); using E = decltype(e);
...@@ -54,7 +54,7 @@ SCENARIO( "empty can be used with tap and submit", "[empty][deferred]" ) { ...@@ -54,7 +54,7 @@ SCENARIO( "empty can be used with tap and submit", "[empty][deferred]" ) {
} }
} }
GIVEN( "An empty int single_deferred" ) { GIVEN( "An empty int single_sender" ) {
auto e = op::empty<int>(); auto e = op::empty<int>();
using E = decltype(e); using E = decltype(e);
...@@ -80,9 +80,9 @@ SCENARIO( "empty can be used with tap and submit", "[empty][deferred]" ) { ...@@ -80,9 +80,9 @@ SCENARIO( "empty can be used with tap and submit", "[empty][deferred]" ) {
} }
} }
SCENARIO( "just() can be used with transform and submit", "[just][deferred]" ) { SCENARIO( "just() can be used with transform and submit", "[just][sender]" ) {
GIVEN( "A just int single_deferred" ) { GIVEN( "A just int single_sender" ) {
auto j = op::just(20); auto j = op::just(20);
using J = decltype(j); using J = decltype(j);
...@@ -119,9 +119,9 @@ SCENARIO( "just() can be used with transform and submit", "[just][deferred]" ) { ...@@ -119,9 +119,9 @@ SCENARIO( "just() can be used with transform and submit", "[just][deferred]" ) {
} }
} }
SCENARIO( "from() can be used with transform and submit", "[from][deferred]" ) { SCENARIO( "from() can be used with transform and submit", "[from][sender]" ) {
GIVEN( "A from int many_deferred" ) { GIVEN( "A from int many_sender" ) {
int arr[] = {0, 9, 99}; int arr[] = {0, 9, 99};
auto m = op::from(arr); auto m = op::from(arr);
using M = decltype(m); using M = decltype(m);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
using namespace std::literals; using namespace std::literals;
#include "pushmi/flow_single_deferred.h" #include "pushmi/flow_single_sender.h"
#include "pushmi/o/empty.h" #include "pushmi/o/empty.h"
#include "pushmi/o/just.h" #include "pushmi/o/just.h"
#include "pushmi/o/on.h" #include "pushmi/o/on.h"
...@@ -34,9 +34,9 @@ struct countdownsingle { ...@@ -34,9 +34,9 @@ struct countdownsingle {
} }
}; };
SCENARIO( "trampoline executor", "[trampoline][deferred]" ) { SCENARIO( "trampoline executor", "[trampoline][sender]" ) {
GIVEN( "A trampoline time_single_deferred" ) { GIVEN( "A trampoline time_single_sender" ) {
auto tr = v::trampoline(); auto tr = v::trampoline();
using TR = decltype(tr); using TR = decltype(tr);
...@@ -135,14 +135,14 @@ SCENARIO( "trampoline executor", "[trampoline][deferred]" ) { ...@@ -135,14 +135,14 @@ SCENARIO( "trampoline executor", "[trampoline][deferred]" ) {
WHEN( "used with on" ) { WHEN( "used with on" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto deferred = pushmi::make_single_deferred([](auto out) { auto sender = pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::pushmi::set_value(out, 2.0);
// ignored // ignored
::pushmi::set_value(out, 1); ::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
deferred | op::on([&](){return tr;}) | sender | op::on([&](){return tr;}) |
op::submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
THEN( "only the first item was pushed" ) { THEN( "only the first item was pushed" ) {
REQUIRE(values == std::vector<std::string>{"2.000000"}); REQUIRE(values == std::vector<std::string>{"2.000000"});
...@@ -151,14 +151,14 @@ SCENARIO( "trampoline executor", "[trampoline][deferred]" ) { ...@@ -151,14 +151,14 @@ SCENARIO( "trampoline executor", "[trampoline][deferred]" ) {
WHEN( "used with via" ) { WHEN( "used with via" ) {
std::vector<std::string> values; std::vector<std::string> values;
auto deferred = pushmi::make_single_deferred([](auto out) { auto sender = pushmi::make_single_sender([](auto out) {
::pushmi::set_value(out, 2.0); ::pushmi::set_value(out, 2.0);
// ignored // ignored
::pushmi::set_value(out, 1); ::pushmi::set_value(out, 1);
::pushmi::set_value(out, std::numeric_limits<int8_t>::min()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::min());
::pushmi::set_value(out, std::numeric_limits<int8_t>::max()); ::pushmi::set_value(out, std::numeric_limits<int8_t>::max());
}); });
deferred | op::via([&](){return tr;}) | sender | op::via([&](){return tr;}) |
op::submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); })); op::submit(v::on_value([&](auto v) { values.push_back(std::to_string(v)); }));
THEN( "only the first item was pushed" ) { THEN( "only the first item was pushed" ) {
REQUIRE(values == std::vector<std::string>{"2.000000"}); REQUIRE(values == std::vector<std::string>{"2.000000"});
......
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