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

force newlines and lint

Summary: discovered that trailing single-line comment token will force clang-format to keep a new-line. used this and clang format to get some of the files clang-format clean while still being more-or-less readable

Reviewed By: yfeldblum

Differential Revision: D13016291

fbshipit-source-id: 0c3428e52f3366d9d90b32a551d8853d163b8298
parent 10da1e9d
...@@ -34,7 +34,8 @@ struct has_cardinality : category_query<PS, cardinality_category> {}; ...@@ -34,7 +34,8 @@ struct has_cardinality : category_query<PS, cardinality_category> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool has_cardinality_v = has_cardinality<PS>::value; PUSHMI_INLINE_VAR constexpr bool has_cardinality_v = has_cardinality<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept Cardinality, template(class PS) //
concept Cardinality, //
has_cardinality_v<PS>); has_cardinality_v<PS>);
// flow affects both sender and receiver // flow affects both sender and receiver
...@@ -75,7 +76,10 @@ template <class PS> ...@@ -75,7 +76,10 @@ template <class PS>
struct is_single<PS> : property_query<PS, is_single<>> {}; struct is_single<PS> : property_query<PS, is_single<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_single_v = is_single<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_single_v = is_single<PS>::value;
PUSHMI_CONCEPT_DEF(template(class PS) concept Single, is_single_v<PS>); PUSHMI_CONCEPT_DEF(
template(class PS) //
concept Single, //
is_single_v<PS>);
// Many trait and tag // Many trait and tag
template <class... TN> template <class... TN>
...@@ -90,7 +94,10 @@ template <class PS> ...@@ -90,7 +94,10 @@ template <class PS>
struct is_many<PS> : property_query<PS, is_many<>> {}; struct is_many<PS> : property_query<PS, is_many<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_many_v = is_many<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_many_v = is_many<PS>::value;
PUSHMI_CONCEPT_DEF(template(class PS) concept Many, is_many_v<PS>); PUSHMI_CONCEPT_DEF(
template(class PS) //
concept Many, //
is_many_v<PS>);
// Flow trait and tag // Flow trait and tag
template <class... TN> template <class... TN>
...@@ -105,7 +112,10 @@ template <class PS> ...@@ -105,7 +112,10 @@ template <class PS>
struct is_flow<PS> : property_query<PS, is_flow<>> {}; struct is_flow<PS> : property_query<PS, is_flow<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_flow_v = is_flow<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_flow_v = is_flow<PS>::value;
PUSHMI_CONCEPT_DEF(template(class PS) concept Flow, is_flow_v<PS>); PUSHMI_CONCEPT_DEF(
template(class PS) //
concept Flow, //
is_flow_v<PS>);
// Receiver trait and tag // Receiver trait and tag
template <class... TN> template <class... TN>
...@@ -159,7 +169,8 @@ struct is_executor<PS> : property_query<PS, is_executor<>> {}; ...@@ -159,7 +169,8 @@ struct is_executor<PS> : property_query<PS, is_executor<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_executor_v = is_executor<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_executor_v = is_executor<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept Executor, template(class PS) //
concept Executor, //
is_executor_v<PS>&& is_sender_v<PS>&& is_single_v<PS>); is_executor_v<PS>&& is_sender_v<PS>&& is_single_v<PS>);
// Constrained trait and tag // Constrained trait and tag
...@@ -174,7 +185,8 @@ struct is_constrained<PS> : property_query<PS, is_constrained<>> {}; ...@@ -174,7 +185,8 @@ struct is_constrained<PS> : property_query<PS, is_constrained<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_constrained_v = is_constrained<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_constrained_v = is_constrained<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept Constrained, template(class PS) //
concept Constrained, //
is_constrained_v<PS>&& is_sender_v<PS>); is_constrained_v<PS>&& is_sender_v<PS>);
// Time trait and tag // Time trait and tag
...@@ -189,7 +201,8 @@ struct is_time<PS> : property_query<PS, is_time<>> {}; ...@@ -189,7 +201,8 @@ struct is_time<PS> : property_query<PS, is_time<>> {};
template <class PS> template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_time_v = is_time<PS>::value; PUSHMI_INLINE_VAR constexpr bool is_time_v = is_time<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept Time, template(class PS) //
concept Time, //
is_time_v<PS>&& is_constrained_v<PS>&& is_sender_v<PS>); is_time_v<PS>&& is_constrained_v<PS>&& is_sender_v<PS>);
// AlwaysBlocking trait and tag // AlwaysBlocking trait and tag
...@@ -207,7 +220,8 @@ template <class PS> ...@@ -207,7 +220,8 @@ template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_always_blocking_v = PUSHMI_INLINE_VAR constexpr bool is_always_blocking_v =
is_always_blocking<PS>::value; is_always_blocking<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept AlwaysBlocking, template(class PS) //
concept AlwaysBlocking, //
is_always_blocking_v<PS>&& is_sender_v<PS>); is_always_blocking_v<PS>&& is_sender_v<PS>);
// NeverBlocking trait and tag // NeverBlocking trait and tag
...@@ -225,7 +239,8 @@ template <class PS> ...@@ -225,7 +239,8 @@ template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_never_blocking_v = PUSHMI_INLINE_VAR constexpr bool is_never_blocking_v =
is_never_blocking<PS>::value; is_never_blocking<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept NeverBlocking, template(class PS) //
concept NeverBlocking, //
is_never_blocking_v<PS>&& is_sender_v<PS>); is_never_blocking_v<PS>&& is_sender_v<PS>);
// MaybeBlocking trait and tag // MaybeBlocking trait and tag
...@@ -243,7 +258,8 @@ template <class PS> ...@@ -243,7 +258,8 @@ template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_maybe_blocking_v = PUSHMI_INLINE_VAR constexpr bool is_maybe_blocking_v =
is_maybe_blocking<PS>::value; is_maybe_blocking<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept MaybeBlocking, template(class PS) //
concept MaybeBlocking, //
is_maybe_blocking_v<PS>&& is_sender_v<PS>); is_maybe_blocking_v<PS>&& is_sender_v<PS>);
// FifoSequence trait and tag // FifoSequence trait and tag
...@@ -261,7 +277,8 @@ template <class PS> ...@@ -261,7 +277,8 @@ template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_fifo_sequence_v = PUSHMI_INLINE_VAR constexpr bool is_fifo_sequence_v =
is_fifo_sequence<PS>::value; is_fifo_sequence<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept FifoSequence, template(class PS) //
concept FifoSequence, //
is_fifo_sequence_v<PS>&& is_sender_v<PS>); is_fifo_sequence_v<PS>&& is_sender_v<PS>);
// ConcurrentSequence trait and tag // ConcurrentSequence trait and tag
...@@ -280,43 +297,51 @@ template <class PS> ...@@ -280,43 +297,51 @@ template <class PS>
PUSHMI_INLINE_VAR constexpr bool is_concurrent_sequence_v = PUSHMI_INLINE_VAR constexpr bool is_concurrent_sequence_v =
is_concurrent_sequence<PS>::value; is_concurrent_sequence<PS>::value;
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class PS) concept ConcurrentSequence, template(class PS) //
concept ConcurrentSequence, //
is_concurrent_sequence_v<PS>&& is_sender_v<PS>); is_concurrent_sequence_v<PS>&& is_sender_v<PS>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class... PropertyN)(concept Receiver)(R, PropertyN...), template(class R, class... PropertyN) //
requires(R& r)( (concept Receiver)(R, PropertyN...), //
requires(R& r)( //
set_done(r), set_done(r),
set_error(r, std::exception_ptr{})) && set_error(r, std::exception_ptr{})) &&
SemiMovable<R> && property_query_v<R, PropertyN...> && SemiMovable<R> && property_query_v<R, PropertyN...> &&
is_receiver_v<R> && !is_sender_v<R>); is_receiver_v<R> && !is_sender_v<R>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class... VN)(concept ReceiveValue)(R, VN...), template(class R, class... VN) //
requires(R& r)(set_value(r, std::declval<VN&&>()...)) && (concept ReceiveValue)(R, VN...), //
requires(R& r)( //
set_value(r, std::declval<VN&&>()...)) &&
Receiver<R> && Receiver<R> &&
// GCC w/-fconcepts ICE on SemiMovable<VN>... // GCC w/-fconcepts ICE on SemiMovable<VN>...
True<> // And<SemiMovable<VN>...> True<> // And<SemiMovable<VN>...>
); );
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class E = std::exception_ptr)(concept ReceiveError)(R, E), template(class R, class E = std::exception_ptr) //
requires(R& r, E&& e)(set_error(r, (E &&) e)) && Receiver<R> && (concept ReceiveError)(R, E), //
SemiMovable<E>); requires(R& r, E&& e)( //
set_error(r, (E &&) e)) &&
Receiver<R> && SemiMovable<E>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)(concept Sender)(D, PropertyN...), template(class D, class... PropertyN) //
requires(D& d)( (concept Sender)(D, PropertyN...), //
requires(D& d)( //
executor(d), executor(d),
requires_<Executor<decltype(executor(d))>>) && requires_<Executor<decltype(executor(d))>>) &&
SemiMovable<D> && Cardinality<D> && property_query_v<D, PropertyN...> && SemiMovable<D> && Cardinality<D> && property_query_v<D, PropertyN...> &&
is_sender_v<D> && !is_receiver_v<D>); is_sender_v<D> && !is_receiver_v<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN) //
concept SenderTo)(D, S, PropertyN...), (concept SenderTo)(D, S, PropertyN...), //
requires(D& d, S&& s)(submit(d, (S &&) s)) && Sender<D> && requires(D& d, S&& s)( //
Receiver<S> && property_query_v<D, PropertyN...>); submit(d, (S &&) s)) &&
Sender<D> && Receiver<S> && property_query_v<D, PropertyN...>);
template <class D> template <class D>
PUSHMI_PP_CONSTRAINED_USING( PUSHMI_PP_CONSTRAINED_USING(
...@@ -328,30 +353,35 @@ PUSHMI_PP_CONSTRAINED_USING( ...@@ -328,30 +353,35 @@ PUSHMI_PP_CONSTRAINED_USING(
// //
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class S, class... PropertyN)( template(class S, class... PropertyN) //
concept FlowReceiver)(S, PropertyN...), (concept FlowReceiver)(S, PropertyN...), //
Receiver<S>&& property_query_v<S, PropertyN...>&& Flow<S>); Receiver<S>&& property_query_v<S, PropertyN...>&& Flow<S>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class... VN)(concept FlowReceiveValue)(R, VN...), template(class R, class... VN) //
(concept FlowReceiveValue)(R, VN...), //
Flow<R>&& ReceiveValue<R, VN...>); Flow<R>&& ReceiveValue<R, VN...>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class E = std::exception_ptr)( template(class R, class E = std::exception_ptr) //
concept FlowReceiveError)(R, E), (concept FlowReceiveError)(R, E), //
Flow<R>&& ReceiveError<R, E>); Flow<R>&& ReceiveError<R, E>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R, class Up)(concept FlowUpTo)(R, Up), template(class R, class Up) //
requires(R& r, Up&& up)(set_starting(r, (Up &&) up)) && Flow<R>); (concept FlowUpTo)(R, Up), //
requires(R& r, Up&& up)( //
set_starting(r, (Up &&) up)) &&
Flow<R>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class S, class... PropertyN)(concept FlowSender)(S, PropertyN...), template(class S, class... PropertyN) //
(concept FlowSender)(S, PropertyN...), //
Sender<S>&& property_query_v<S, PropertyN...>&& Flow<S>); Sender<S>&& property_query_v<S, PropertyN...>&& Flow<S>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN) //
concept FlowSenderTo)(D, S, PropertyN...), (concept FlowSenderTo)(D, S, PropertyN...), //
FlowSender<D>&& property_query_v<D, PropertyN...>&& FlowReceiver<S>); FlowSender<D>&& property_query_v<D, PropertyN...>&& FlowReceiver<S>);
// add concepts for constraints // add concepts for constraints
...@@ -364,17 +394,18 @@ PUSHMI_CONCEPT_DEF( ...@@ -364,17 +394,18 @@ PUSHMI_CONCEPT_DEF(
// //
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)( template(class D, class... PropertyN) //
concept ConstrainedSender)(D, PropertyN...), (concept ConstrainedSender)(D, PropertyN...), //
requires(D& d)( requires(D& d)( //
top(d), top(d),
requires_<Regular<decltype(top(d))>>) && requires_<Regular<decltype(top(d))>>) &&
Sender<D> && property_query_v<D, PropertyN...> && Constrained<D>); Sender<D> && property_query_v<D, PropertyN...> && Constrained<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN) //
concept ConstrainedSenderTo)(D, S, PropertyN...), (concept ConstrainedSenderTo)(D, S, PropertyN...), //
requires(D& d, S&& s)(submit(d, top(d), (S &&) s)) && requires(D& d, S&& s)( //
submit(d, top(d), (S &&) s)) &&
ConstrainedSender<D> && property_query_v<D, PropertyN...> && ConstrainedSender<D> && property_query_v<D, PropertyN...> &&
Receiver<S>); Receiver<S>);
...@@ -385,16 +416,16 @@ PUSHMI_PP_CONSTRAINED_USING( ...@@ -385,16 +416,16 @@ PUSHMI_PP_CONSTRAINED_USING(
decltype(top(std::declval<D&>()))); decltype(top(std::declval<D&>())));
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class... PropertyN)(concept TimeSender)(D, PropertyN...), template(class D, class... PropertyN) //
requires(D& d)( (concept TimeSender)(D, PropertyN...), //
requires(D& d)( //
now(d), now(d),
requires_< requires_<Regular<decltype(now(d) + std::chrono::seconds(1))>>) &&
Regular<decltype(now(d) + std::chrono::seconds(1))>>) &&
ConstrainedSender<D, PropertyN...> && Time<D>); ConstrainedSender<D, PropertyN...> && Time<D>);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class D, class S, class... PropertyN)( template(class D, class S, class... PropertyN) //
concept TimeSenderTo)(D, S, PropertyN...), (concept TimeSenderTo)(D, S, PropertyN...), //
ConstrainedSenderTo<D, S, PropertyN...>&& TimeSender<D>); ConstrainedSenderTo<D, S, PropertyN...>&& TimeSender<D>);
template <class D> template <class D>
......
...@@ -105,8 +105,9 @@ class any_many_sender { ...@@ -105,8 +105,9 @@ class any_many_sender {
(requires SenderTo< (requires SenderTo<
wrapped_t<Wrapped>, wrapped_t<Wrapped>,
any_receiver<E, VN...>, any_receiver<E, VN...>,
is_many<>>) is_many<>>) //
explicit any_many_sender(Wrapped obj) noexcept(insitu<Wrapped>()) explicit any_many_sender(Wrapped obj) //
noexcept(insitu<Wrapped>())
: any_many_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : any_many_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_many_sender() { ~any_many_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
...@@ -146,9 +147,9 @@ class many_sender<SF, EXF> { ...@@ -146,9 +147,9 @@ class many_sender<SF, EXF> {
return exf_(); return exf_();
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(lazy::Receiver<Out> PUSHMI_AND (requires PUSHMI_EXP(
lazy::Invocable<SF&, Out>)) lazy::Receiver<Out> PUSHMI_AND lazy::Invocable<SF&, Out>)) //
void submit(Out out) { void submit(Out out) {
sf_(std::move(out)); sf_(std::move(out));
} }
}; };
...@@ -176,9 +177,8 @@ class many_sender<Data, DSF, DEXF> { ...@@ -176,9 +177,8 @@ class many_sender<Data, DSF, DEXF> {
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP( (requires PUSHMI_EXP(
lazy::Receiver<Out> PUSHMI_AND lazy::Receiver<Out> PUSHMI_AND lazy::Invocable<DSF&, Data&, Out>)) //
lazy::Invocable<DSF&, Data&, Out>)) void submit(Out out) {
void submit(Out out) {
sf_(data_, std::move(out)); sf_(data_, std::move(out));
} }
}; };
...@@ -196,59 +196,72 @@ PUSHMI_INLINE_VAR constexpr struct make_many_sender_fn { ...@@ -196,59 +196,72 @@ PUSHMI_INLINE_VAR constexpr struct make_many_sender_fn {
return many_sender<ignoreSF, trampolineEXF>{}; return many_sender<ignoreSF, trampolineEXF>{};
} }
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_sender<SF, trampolineEXF>{std::move(sf)}; return many_sender<SF, trampolineEXF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class SF, class EXF) PUSHMI_TEMPLATE(class SF, class EXF)
(requires True<> && Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<>&& Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(
auto operator()(SF sf, EXF exf) const { &&not Sender<SF>)) //
auto
operator()(SF sf, EXF exf) const {
return many_sender<SF, EXF>{std::move(sf), std::move(exf)}; return many_sender<SF, EXF>{std::move(sf), std::move(exf)};
} }
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_sender<Data, passDSF, passDEXF>{std::move(d)}; return many_sender<Data, passDSF, passDEXF>{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_sender<Data, DSF, passDEXF>{std::move(d), std::move(sf)}; return many_sender<Data, DSF, passDEXF>{std::move(d), std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data, class DSF, class DEXF) PUSHMI_TEMPLATE(class Data, class DSF, class DEXF)
(requires Sender<Data, is_many<>> && Invocable<DEXF&, Data&>) (requires Sender<Data, is_many<>>&& Invocable<DEXF&, Data&>) //
auto operator()(Data d, DSF sf, DEXF exf) const { auto
return many_sender<Data, DSF, DEXF>{std::move(d), std::move(sf), std::move(exf)}; operator()(Data d, DSF sf, DEXF exf) const {
return many_sender<Data, DSF, DEXF>{
std::move(d), std::move(sf), std::move(exf)};
} }
} const make_many_sender {}; } const make_many_sender{};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
many_sender() -> many_sender<ignoreSF, trampolineEXF>; many_sender()->many_sender<ignoreSF, trampolineEXF>;
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_sender(SF) -> many_sender<SF, trampolineEXF>; many_sender(SF)
->many_sender<SF, trampolineEXF>;
PUSHMI_TEMPLATE(class SF, class EXF) PUSHMI_TEMPLATE(class SF, class EXF)
(requires True<> && Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) (requires True<>&& Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(
many_sender(SF, EXF) -> many_sender<SF, EXF>; &&not Sender<SF>)) //
many_sender(SF, EXF)
->many_sender<SF, EXF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_many<>>) (requires True<>&& Sender<Data, is_many<>>) //
many_sender(Data) -> many_sender<Data, passDSF, passDEXF>; many_sender(Data)
->many_sender<Data, passDSF, passDEXF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_many<>>) (requires Sender<Data, is_many<>>) //
many_sender(Data, DSF) -> many_sender<Data, DSF, passDEXF>; many_sender(Data, DSF)
->many_sender<Data, DSF, passDEXF>;
PUSHMI_TEMPLATE(class Data, class DSF, class DEXF) PUSHMI_TEMPLATE(class Data, class DSF, class DEXF)
(requires Sender<Data, is_many<>> && Invocable<DEXF&, Data&>) (requires Sender<Data, is_many<>>&& Invocable<DEXF&, Data&>) //
many_sender(Data, DSF, DEXF) -> many_sender<Data, DSF, DEXF>; many_sender(Data, DSF, DEXF)
->many_sender<Data, DSF, DEXF>;
#endif #endif
template<> template <>
struct construct_deduced<many_sender> : make_many_sender_fn {}; struct construct_deduced<many_sender> : make_many_sender_fn {};
} // namespace pushmi } // namespace pushmi
......
...@@ -32,10 +32,9 @@ struct single_empty_sender_base : single_sender<ignoreSF, inlineEXF> { ...@@ -32,10 +32,9 @@ struct single_empty_sender_base : single_sender<ignoreSF, inlineEXF> {
template <class... VN> template <class... VN>
struct single_empty_impl { struct single_empty_impl {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue<Out, VN...>) (requires ReceiveValue<Out, VN...>) //
void operator()( void
single_empty_sender_base&, operator()(single_empty_sender_base&, Out out) {
Out out) {
set_done(out); set_done(out);
} }
}; };
......
...@@ -25,11 +25,10 @@ namespace folly { ...@@ -25,11 +25,10 @@ namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class R) template(class R) //
concept Range, concept Range, //
requires(R&& r)( requires(R&& r)( //
implicitly_convertible_to<bool>(std::begin(r) == std::end(r))) implicitly_convertible_to<bool>(std::begin(r) == std::end(r))));
);
namespace operators { namespace operators {
...@@ -49,8 +48,9 @@ PUSHMI_INLINE_VAR constexpr struct from_fn { ...@@ -49,8 +48,9 @@ PUSHMI_INLINE_VAR constexpr struct from_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue< (requires ReceiveValue<
Out, Out,
typename std::iterator_traits<I>::value_type>) typename std::iterator_traits<I>::value_type>) //
void operator()(sender_base&, Out out) const { void
operator()(sender_base&, Out out) const {
auto c = begin_; auto c = begin_;
for (; c != end_; ++c) { for (; c != end_; ++c) {
set_value(out, *c); set_value(out, *c);
...@@ -63,14 +63,16 @@ PUSHMI_INLINE_VAR constexpr struct from_fn { ...@@ -63,14 +63,16 @@ PUSHMI_INLINE_VAR constexpr struct from_fn {
PUSHMI_TEMPLATE(class I, class S) PUSHMI_TEMPLATE(class I, class S)
(requires DerivedFrom< (requires DerivedFrom<
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_sender(sender_base{}, out_impl<I, S>{begin, end}); return make_many_sender(sender_base{}, out_impl<I, S>{begin, end});
} }
PUSHMI_TEMPLATE(class R) PUSHMI_TEMPLATE(class R)
(requires Range<R>) (requires Range<R>) //
auto operator()(R&& range) const { auto
operator()(R&& range) const {
return (*this)(std::begin(range), std::end(range)); return (*this)(std::begin(range), std::end(range));
} }
} from{}; } from{};
...@@ -144,8 +146,9 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn { ...@@ -144,8 +146,9 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue< (requires ReceiveValue<
Out, Out,
typename std::iterator_traits<I>::value_type>) typename std::iterator_traits<I>::value_type>) //
void operator()(Out out) const { void
operator()(Out out) const {
using Producer = flow_from_producer<I, S, Out, Exec>; using Producer = flow_from_producer<I, S, Out, Exec>;
auto p = std::make_shared<Producer>( auto p = std::make_shared<Producer>(
begin_, end_, std::move(out), exec_, false); begin_, end_, std::move(out), exec_, false);
...@@ -162,30 +165,32 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn { ...@@ -162,30 +165,32 @@ PUSHMI_INLINE_VAR constexpr struct flow_from_fn {
PUSHMI_TEMPLATE(class I, class S) PUSHMI_TEMPLATE(class I, class S)
(requires DerivedFrom< (requires DerivedFrom<
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 (*this)(begin, end, trampoline()); return (*this)(begin, end, trampoline());
} }
PUSHMI_TEMPLATE(class R) PUSHMI_TEMPLATE(class R)
(requires Range<R>) (requires Range<R>) //
auto operator()(R&& range) const { auto
operator()(R&& range) const {
return (*this)(std::begin(range), std::end(range), trampoline()); return (*this)(std::begin(range), std::end(range), trampoline());
} }
PUSHMI_TEMPLATE(class I, class S, class Exec) PUSHMI_TEMPLATE(class I, class S, class Exec)
(requires DerivedFrom< (requires DerivedFrom<
typename std::iterator_traits<I>::iterator_category, typename std::iterator_traits<I>::iterator_category,
std::forward_iterator_tag>&& Sender<Exec, is_single<>, is_executor<>>) std::forward_iterator_tag>&& Sender<Exec, is_single<>, is_executor<>>) //
auto operator()(I begin, S end, Exec exec) const { auto
operator()(I begin, S end, Exec exec) const {
return make_flow_many_sender(out_impl<I, S, Exec>{begin, end, exec}); return make_flow_many_sender(out_impl<I, S, Exec>{begin, end, exec});
} }
PUSHMI_TEMPLATE(class R, class Exec) PUSHMI_TEMPLATE(class R, class Exec)
(requires Range<R>&& Sender<Exec, is_single<>, is_executor<>>) (requires Range<R>&& Sender<Exec, is_single<>, is_executor<>>) //
auto operator()( auto
R&& range, operator()(R&& range, Exec exec) const {
Exec exec) const {
return (*this)(std::begin(range), std::end(range), exec); return (*this)(std::begin(range), std::end(range), exec);
} }
} flow_from{}; } flow_from{};
......
...@@ -37,8 +37,9 @@ PUSHMI_INLINE_VAR constexpr struct just_fn { ...@@ -37,8 +37,9 @@ PUSHMI_INLINE_VAR constexpr struct just_fn {
struct impl { struct impl {
std::tuple<VN...> vn_; std::tuple<VN...> vn_;
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue<Out, VN...>) (requires ReceiveValue<Out, VN...>) //
void operator()(sender_base&, Out out) { void
operator()(sender_base&, Out out) {
::folly::pushmi::apply( ::folly::pushmi::apply(
::folly::pushmi::set_value, ::folly::pushmi::set_value,
std::tuple_cat(std::tuple<Out&>{out}, std::move(vn_))); std::tuple_cat(std::tuple<Out&>{out}, std::move(vn_)));
...@@ -48,8 +49,9 @@ PUSHMI_INLINE_VAR constexpr struct just_fn { ...@@ -48,8 +49,9 @@ PUSHMI_INLINE_VAR constexpr struct just_fn {
public: public:
PUSHMI_TEMPLATE(class... VN) PUSHMI_TEMPLATE(class... VN)
(requires And<SemiMovable<VN>...>) (requires And<SemiMovable<VN>...>) //
auto operator()(VN... vn) const { auto
operator()(VN... vn) const {
return make_single_sender( return make_single_sender(
sender_base{}, impl<VN...>{std::tuple<VN...>{std::move(vn)...}}); sender_base{}, impl<VN...>{std::tuple<VN...>{std::move(vn)...}});
} }
......
...@@ -38,8 +38,9 @@ struct on_fn { ...@@ -38,8 +38,9 @@ struct on_fn {
struct out_impl { struct out_impl {
ExecutorFactory ef_; ExecutorFactory ef_;
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires SenderTo<In, Out>) (requires SenderTo<In, Out>) //
void operator()(In& in, Out out) const { void
operator()(In& in, Out out) const {
auto exec = ef_(); auto exec = ef_();
submit( submit(
exec, exec,
...@@ -60,8 +61,9 @@ struct on_fn { ...@@ -60,8 +61,9 @@ struct on_fn {
struct time_out_impl { struct time_out_impl {
ExecutorFactory ef_; ExecutorFactory ef_;
PUSHMI_TEMPLATE(class TP, class Out) PUSHMI_TEMPLATE(class TP, class Out)
(requires TimeSenderTo<In, Out>) (requires TimeSenderTo<In, Out>) //
void operator()(In& in, TP at, Out out) const { void
operator()(In& in, TP at, Out out) const {
auto exec = ef_(); auto exec = ef_();
submit( submit(
exec, exec,
...@@ -74,8 +76,9 @@ struct on_fn { ...@@ -74,8 +76,9 @@ struct on_fn {
struct in_impl { struct in_impl {
ExecutorFactory ef_; ExecutorFactory ef_;
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 ::folly::pushmi::detail::sender_from( return ::folly::pushmi::detail::sender_from(
std::move(in), std::move(in),
detail::submit_transform_out<In>( detail::submit_transform_out<In>(
...@@ -87,8 +90,9 @@ struct on_fn { ...@@ -87,8 +90,9 @@ struct on_fn {
public: public:
PUSHMI_TEMPLATE(class ExecutorFactory) PUSHMI_TEMPLATE(class ExecutorFactory)
(requires Invocable<ExecutorFactory&>&& (requires Invocable<ExecutorFactory&>&&
Executor<invoke_result_t<ExecutorFactory&>>) Executor<invoke_result_t<ExecutorFactory&>>) //
auto operator()(ExecutorFactory ef) const { auto
operator()(ExecutorFactory ef) const {
return in_impl<ExecutorFactory>{std::move(ef)}; return in_impl<ExecutorFactory>{std::move(ef)};
} }
}; };
......
...@@ -29,20 +29,17 @@ namespace detail { ...@@ -29,20 +29,17 @@ namespace detail {
namespace submit_detail { namespace submit_detail {
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class In, class... AN)( template(class In, class... AN) //
concept AutoSenderTo)(In, AN...), (concept AutoSenderTo)(In, AN...), //
Sender<In>&& SenderTo<In, receiver_type_t<In, AN...>> Sender<In>&& SenderTo<In, receiver_type_t<In, AN...>>);
);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class In, class... AN)( template(class In, class... AN) //
concept AutoConstrainedSenderTo)(In, AN...), (concept AutoConstrainedSenderTo)(In, AN...), //
ConstrainedSenderTo<In, receiver_type_t<In, AN...>> ConstrainedSenderTo<In, receiver_type_t<In, AN...>>);
);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class In, class... AN)( template(class In, class... AN) //
concept AutoTimeSenderTo)(In, AN...), (concept AutoTimeSenderTo)(In, AN...), //
TimeSenderTo<In, receiver_type_t<In, AN...>> TimeSenderTo<In, receiver_type_t<In, AN...>>);
);
} // namespace submit_detail } // namespace submit_detail
struct submit_fn { struct submit_fn {
...@@ -54,8 +51,9 @@ struct submit_fn { ...@@ -54,8 +51,9 @@ struct submit_fn {
struct fn { struct fn {
std::tuple<AN...> args_; std::tuple<AN...> args_;
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires submit_detail::AutoSenderTo<In, AN...>) (requires submit_detail::AutoSenderTo<In, AN...>) //
In operator()(In in) { In
operator()(In in) {
auto out{ auto out{
::folly::pushmi::detail::receiver_from_fn<In>{}(std::move(args_))}; ::folly::pushmi::detail::receiver_from_fn<In>{}(std::move(args_))};
::folly::pushmi::submit(in, std::move(out)); ::folly::pushmi::submit(in, std::move(out));
...@@ -77,8 +75,9 @@ struct submit_at_fn { ...@@ -77,8 +75,9 @@ struct submit_at_fn {
TP at_; TP at_;
std::tuple<AN...> args_; std::tuple<AN...> args_;
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires submit_detail::AutoTimeSenderTo<In, AN...>) (requires submit_detail::AutoTimeSenderTo<In, AN...>) //
In operator()(In in) { In
operator()(In in) {
auto out{ auto out{
::folly::pushmi::detail::receiver_from_fn<In>()(std::move(args_))}; ::folly::pushmi::detail::receiver_from_fn<In>()(std::move(args_))};
::folly::pushmi::submit(in, std::move(at_), std::move(out)); ::folly::pushmi::submit(in, std::move(at_), std::move(out));
...@@ -88,8 +87,9 @@ struct submit_at_fn { ...@@ -88,8 +87,9 @@ struct submit_at_fn {
public: public:
PUSHMI_TEMPLATE(class TP, class... AN) PUSHMI_TEMPLATE(class TP, class... AN)
(requires Regular<TP>) (requires Regular<TP>) //
auto operator()(TP at, AN... an) const { auto
operator()(TP at, AN... an) const {
return submit_at_fn::fn<TP, AN...>{std::move(at), return submit_at_fn::fn<TP, AN...>{std::move(at),
std::tuple<AN...>{(AN &&) an...}}; std::tuple<AN...>{(AN &&) an...}};
} }
...@@ -102,8 +102,9 @@ struct submit_after_fn { ...@@ -102,8 +102,9 @@ struct submit_after_fn {
D after_; D after_;
std::tuple<AN...> args_; std::tuple<AN...> args_;
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires submit_detail::AutoTimeSenderTo<In, AN...>) (requires submit_detail::AutoTimeSenderTo<In, AN...>) //
In operator()(In in) { In
operator()(In in) {
// TODO - only move, move-only types.. // TODO - only move, move-only types..
// if out can be copied, then submit can be called multiple // if out can be copied, then submit can be called multiple
// times.. // times..
...@@ -117,8 +118,9 @@ struct submit_after_fn { ...@@ -117,8 +118,9 @@ struct submit_after_fn {
public: public:
PUSHMI_TEMPLATE(class D, class... AN) PUSHMI_TEMPLATE(class D, class... AN)
(requires Regular<D>) (requires Regular<D>) //
auto operator()(D after, AN... an) const { auto
operator()(D after, AN... an) const {
return submit_after_fn::fn<D, AN...>{std::move(after), return submit_after_fn::fn<D, AN...>{std::move(after),
std::tuple<AN...>{(AN &&) an...}}; std::tuple<AN...>{(AN &&) an...}};
} }
...@@ -135,8 +137,8 @@ struct blocking_submit_fn { ...@@ -135,8 +137,8 @@ struct blocking_submit_fn {
template <class Out> template <class Out>
struct nested_receiver_impl; struct nested_receiver_impl;
PUSHMI_TEMPLATE(class Exec) PUSHMI_TEMPLATE(class Exec)
(requires Sender<Exec>&& Executor<Exec>) (requires Sender<Exec>&& Executor<Exec>) //
struct nested_executor_impl { struct nested_executor_impl {
nested_executor_impl(lock_state* state, Exec ex) nested_executor_impl(lock_state* state, Exec ex)
: state_(state), ex_(std::move(ex)) {} : state_(state), ex_(std::move(ex)) {}
lock_state* state_; lock_state* state_;
...@@ -146,15 +148,14 @@ struct blocking_submit_fn { ...@@ -146,15 +148,14 @@ struct blocking_submit_fn {
using test_for_this = nested_executor_impl<U>; using test_for_this = nested_executor_impl<U>;
PUSHMI_TEMPLATE(class Ex) PUSHMI_TEMPLATE(class Ex)
(requires Sender<Ex>&& Executor<Ex>&& (requires Sender<Ex>&& Executor<Ex>&& detail::is_v<Ex, test_for_this>) //
detail::is_v<Ex, test_for_this>) static auto make(lock_state*, Ex ex) {
static auto make(lock_state*, Ex ex) {
return ex; return ex;
} }
PUSHMI_TEMPLATE(class Ex) PUSHMI_TEMPLATE(class Ex)
(requires Sender<Ex>&& Executor<Ex> && (requires Sender<Ex>&& Executor<Ex> &&
not detail::is_v<Ex, test_for_this>) not detail::is_v<Ex, test_for_this>) //
static auto make(lock_state* state, Ex ex) { static auto make(lock_state* state, Ex ex) {
return nested_executor_impl<Ex>{state, ex}; return nested_executor_impl<Ex>{state, ex};
} }
...@@ -165,22 +166,22 @@ struct blocking_submit_fn { ...@@ -165,22 +166,22 @@ struct blocking_submit_fn {
} }
PUSHMI_TEMPLATE(class... ZN) PUSHMI_TEMPLATE(class... ZN)
(requires Constrained<Exec>) (requires Constrained<Exec>) //
auto top() { auto top() {
return ::folly::pushmi::top(ex_); return ::folly::pushmi::top(ex_);
} }
PUSHMI_TEMPLATE(class CV, class Out) PUSHMI_TEMPLATE(class CV, class Out)
(requires Receiver<Out>&& Constrained<Exec>) (requires Receiver<Out>&& Constrained<Exec>) //
void submit(CV cv, Out out) { void submit(CV cv, Out out) {
++state_->nested; ++state_->nested;
::folly::pushmi::submit( ::folly::pushmi::submit(
ex_, cv, nested_receiver_impl<Out>{state_, std::move(out)}); ex_, cv, nested_receiver_impl<Out>{state_, std::move(out)});
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out> && not Constrained<Exec>) (requires Receiver<Out> && not Constrained<Exec>) //
void submit(Out out) { void submit(Out out) {
++state_->nested; ++state_->nested;
::folly::pushmi::submit( ::folly::pushmi::submit(
ex_, nested_receiver_impl<Out>{state_, std::move(out)}); ex_, nested_receiver_impl<Out>{state_, std::move(out)});
...@@ -226,8 +227,9 @@ struct blocking_submit_fn { ...@@ -226,8 +227,9 @@ struct blocking_submit_fn {
}; };
struct nested_executor_impl_fn { struct nested_executor_impl_fn {
PUSHMI_TEMPLATE(class Exec) PUSHMI_TEMPLATE(class Exec)
(requires Executor<Exec>) (requires Executor<Exec>) //
auto operator()(lock_state* state, Exec ex) const { auto
operator()(lock_state* state, Exec ex) const {
return nested_executor_impl<Exec>::make(state, std::move(ex)); return nested_executor_impl<Exec>::make(state, std::move(ex));
} }
}; };
...@@ -239,8 +241,9 @@ struct blocking_submit_fn { ...@@ -239,8 +241,9 @@ struct blocking_submit_fn {
::folly::pushmi::invoke_result_t< ::folly::pushmi::invoke_result_t<
nested_executor_impl_fn, nested_executor_impl_fn,
lock_state*, lock_state*,
std::decay_t<Value>>>) std::decay_t<Value>>>) //
void operator()(Out out, Value&& v) const { void
operator()(Out out, Value&& v) const {
++state_->nested; ++state_->nested;
set_value(out, nested_executor_impl_fn{}(state_, (Value &&) v)); set_value(out, nested_executor_impl_fn{}(state_, (Value &&) v));
if (--state_->nested == 0) { if (--state_->nested == 0) {
...@@ -250,16 +253,18 @@ struct blocking_submit_fn { ...@@ -250,16 +253,18 @@ struct blocking_submit_fn {
} }
PUSHMI_TEMPLATE(class Out, class... VN) PUSHMI_TEMPLATE(class Out, class... VN)
(requires True<>&& ReceiveValue<Out, VN...> && (requires True<>&& ReceiveValue<Out, VN...> &&
not(sizeof...(VN) == 1 && And<Executor<std::decay_t<VN>>...>)) not(sizeof...(VN) == 1 && And<Executor<std::decay_t<VN>>...>)) //
void operator()(Out out, VN&&... vn) const { void
operator()(Out out, VN&&... vn) const {
set_value(out, (VN &&) vn...); set_value(out, (VN &&) vn...);
} }
}; };
struct on_error_impl { struct on_error_impl {
lock_state* state_; lock_state* state_;
PUSHMI_TEMPLATE(class Out, class E) PUSHMI_TEMPLATE(class Out, class E)
(requires ReceiveError<Out, E>) (requires ReceiveError<Out, E>) //
void operator()(Out out, E e) const noexcept { void
operator()(Out out, E e) const noexcept {
set_error(out, std::move(e)); set_error(out, std::move(e));
std::unique_lock<std::mutex> guard{state_->lock}; std::unique_lock<std::mutex> guard{state_->lock};
state_->done = true; state_->done = true;
...@@ -269,8 +274,9 @@ struct blocking_submit_fn { ...@@ -269,8 +274,9 @@ struct blocking_submit_fn {
struct on_done_impl { struct on_done_impl {
lock_state* state_; lock_state* state_;
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>) (requires Receiver<Out>) //
void operator()(Out out) const { void
operator()(Out out) const {
set_done(out); set_done(out);
std::unique_lock<std::mutex> guard{state_->lock}; std::unique_lock<std::mutex> guard{state_->lock};
state_->done = true; state_->done = true;
...@@ -281,10 +287,9 @@ struct blocking_submit_fn { ...@@ -281,10 +287,9 @@ struct blocking_submit_fn {
template <class In> template <class In>
struct receiver_impl { struct receiver_impl {
PUSHMI_TEMPLATE(class... AN) PUSHMI_TEMPLATE(class... AN)
(requires Sender<In>) (requires Sender<In>) //
auto operator()( auto
lock_state* state, operator()(lock_state* state, std::tuple<AN...> args) const {
std::tuple<AN...> args) const {
return ::folly::pushmi::detail::receiver_from_fn<In>()( return ::folly::pushmi::detail::receiver_from_fn<In>()(
std::move(args), std::move(args),
on_value_impl{state}, on_value_impl{state},
...@@ -295,8 +300,9 @@ struct blocking_submit_fn { ...@@ -295,8 +300,9 @@ struct blocking_submit_fn {
template <class In> template <class In>
struct submit_impl { struct submit_impl {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires Receiver<Out>&& SenderTo<In, Out>) (requires Receiver<Out>&& SenderTo<In, Out>) //
void operator()(In& in, Out out) const { void
operator()(In& in, Out out) const {
::folly::pushmi::submit(in, std::move(out)); ::folly::pushmi::submit(in, std::move(out));
} }
}; };
...@@ -315,8 +321,9 @@ struct blocking_submit_fn { ...@@ -315,8 +321,9 @@ struct blocking_submit_fn {
receiver_impl<In>, receiver_impl<In>,
lock_state*, lock_state*,
std::tuple<AN...>&&>> && std::tuple<AN...>&&>> &&
not AlwaysBlocking<In>) not AlwaysBlocking<In>) //
In operator()(In in) { In
operator()(In in) {
lock_state state{}; lock_state state{};
auto make = receiver_impl<In>{}; auto make = receiver_impl<In>{};
...@@ -361,8 +368,9 @@ struct get_fn { ...@@ -361,8 +368,9 @@ struct get_fn {
public: public:
// TODO constrain this better // TODO constrain this better
PUSHMI_TEMPLATE(class In) PUSHMI_TEMPLATE(class In)
(requires Sender<In>) (requires Sender<In>) //
T operator()(In in) const { T
operator()(In in) const {
::folly::pushmi::detail::opt<T> result_; ::folly::pushmi::detail::opt<T> result_;
::folly::pushmi::detail::opt<std::exception_ptr> ep_; ::folly::pushmi::detail::opt<std::exception_ptr> ep_;
auto out = ::folly::pushmi::make_receiver( auto out = ::folly::pushmi::make_receiver(
......
...@@ -21,8 +21,9 @@ namespace folly { ...@@ -21,8 +21,9 @@ namespace folly {
namespace pushmi { namespace pushmi {
PUSHMI_TEMPLATE(class In, class Op) PUSHMI_TEMPLATE(class In, class Op)
(requires lazy::Sender<std::decay_t<In>>&& lazy::Invocable<Op&, In>) (requires lazy::Sender<std::decay_t<In>>&& lazy::Invocable<Op&, In>) //
decltype(auto) operator|(In&& in, Op op) { decltype(auto)
operator|(In&& in, Op op) {
return op((In &&) in); return op((In &&) in);
} }
......
...@@ -107,8 +107,8 @@ class any_single_sender { ...@@ -107,8 +107,8 @@ class any_single_sender {
wrapped_t<Wrapped>, wrapped_t<Wrapped>,
any_receiver< any_receiver<
E, E,
VN...>>)explicit any_single_sender(Wrapped VN...>>) //
obj) noexcept(insitu<Wrapped>()) explicit any_single_sender(Wrapped obj) noexcept(insitu<Wrapped>())
: any_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {} : any_single_sender{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_single_sender() { ~any_single_sender() {
vptr_->op_(data_, nullptr); vptr_->op_(data_, nullptr);
...@@ -148,9 +148,9 @@ class single_sender<SF, EXF> { ...@@ -148,9 +148,9 @@ class single_sender<SF, EXF> {
return exf_(); return exf_();
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP(lazy::Receiver<Out> PUSHMI_AND (requires PUSHMI_EXP(
lazy::Invocable<SF&, Out>)) lazy::Receiver<Out> PUSHMI_AND lazy::Invocable<SF&, Out>)) //
void submit(Out out) { void submit(Out out) {
sf_(std::move(out)); sf_(std::move(out));
} }
}; };
...@@ -181,9 +181,8 @@ class single_sender<Data, DSF, DEXF> { ...@@ -181,9 +181,8 @@ class single_sender<Data, DSF, DEXF> {
} }
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires PUSHMI_EXP( (requires PUSHMI_EXP(
lazy::Receiver<Out> PUSHMI_AND lazy::Receiver<Out> PUSHMI_AND lazy::Invocable<DSF&, Data&, Out>)) //
lazy::Invocable<DSF&, Data&, Out>)) void submit(Out out) {
void submit(Out out) {
sf_(data_, std::move(out)); sf_(data_, std::move(out));
} }
}; };
...@@ -201,29 +200,34 @@ PUSHMI_INLINE_VAR constexpr struct make_single_sender_fn { ...@@ -201,29 +200,34 @@ PUSHMI_INLINE_VAR constexpr struct make_single_sender_fn {
return single_sender<ignoreSF, trampolineEXF>{}; return single_sender<ignoreSF, trampolineEXF>{};
} }
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_sender<SF, trampolineEXF>{std::move(sf)}; return single_sender<SF, trampolineEXF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class SF, class EXF) PUSHMI_TEMPLATE(class SF, class EXF)
(requires True<>&& Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION( (requires True<>&& Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(
&&not Sender<SF>)) &&not Sender<SF>)) //
auto operator()(SF sf, EXF exf) const { auto
operator()(SF sf, EXF exf) const {
return single_sender<SF, EXF>{std::move(sf), std::move(exf)}; return single_sender<SF, EXF>{std::move(sf), std::move(exf)};
} }
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_sender<Data, passDSF, passDEXF>{std::move(d)}; return single_sender<Data, passDSF, passDEXF>{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_sender<Data, DSF, passDEXF>{std::move(d), std::move(sf)}; return single_sender<Data, DSF, passDEXF>{std::move(d), std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data, class DSF, class DEXF) PUSHMI_TEMPLATE(class Data, class DSF, class DEXF)
(requires Sender<Data, is_single<>>&& Invocable<DEXF&, Data&>) (requires Sender<Data, is_single<>>&& Invocable<DEXF&, Data&>) //
auto operator()(Data d, DSF sf, DEXF exf) const { auto
operator()(Data d, DSF sf, DEXF exf) const {
return single_sender<Data, DSF, DEXF>{ return single_sender<Data, DSF, DEXF>{
std::move(d), std::move(sf), std::move(exf)}; std::move(d), std::move(sf), std::move(exf)};
} }
...@@ -232,31 +236,36 @@ PUSHMI_INLINE_VAR constexpr struct make_single_sender_fn { ...@@ -232,31 +236,36 @@ PUSHMI_INLINE_VAR constexpr struct make_single_sender_fn {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// deduction guides // deduction guides
#if __cpp_deduction_guides >= 201703 #if __cpp_deduction_guides >= 201703
single_sender() -> single_sender<ignoreSF, trampolineEXF>; single_sender()->single_sender<ignoreSF, trampolineEXF>;
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_sender(SF) -> single_sender<SF, trampolineEXF>; single_sender(SF)
->single_sender<SF, trampolineEXF>;
PUSHMI_TEMPLATE(class SF, class EXF) PUSHMI_TEMPLATE(class SF, class EXF)
(requires True<> && Invocable<EXF&> (requires True<>&& Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(
PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>)) &&not Sender<SF>)) //
single_sender(SF, EXF) -> single_sender<SF, EXF>; single_sender(SF, EXF)
->single_sender<SF, EXF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires True<> && Sender<Data, is_single<>>) (requires True<>&& Sender<Data, is_single<>>) //
single_sender(Data) -> single_sender<Data, passDSF, passDEXF>; single_sender(Data)
->single_sender<Data, passDSF, passDEXF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
(requires Sender<Data, is_single<>>) (requires Sender<Data, is_single<>>) //
single_sender(Data, DSF) -> single_sender<Data, DSF, passDEXF>; single_sender(Data, DSF)
->single_sender<Data, DSF, passDEXF>;
PUSHMI_TEMPLATE(class Data, class DSF, class DEXF) PUSHMI_TEMPLATE(class Data, class DSF, class DEXF)
(requires Sender<Data, is_single<>> && Invocable<DEXF&, Data&>) (requires Sender<Data, is_single<>>&& Invocable<DEXF&, Data&>) //
single_sender(Data, DSF, DEXF) -> single_sender<Data, DSF, DEXF>; single_sender(Data, DSF, DEXF)
->single_sender<Data, DSF, DEXF>;
#endif #endif
template<> template <>
struct construct_deduced<single_sender> : make_single_sender_fn {}; struct construct_deduced<single_sender> : make_single_sender_fn {};
} // namespace pushmi } // namespace pushmi
......
...@@ -196,8 +196,7 @@ class strand_executor { ...@@ -196,8 +196,7 @@ class strand_executor {
PUSHMI_TEMPLATE(class Out) PUSHMI_TEMPLATE(class Out)
(requires ReceiveValue<Out, any_executor_ref<E>>&& (requires ReceiveValue<Out, any_executor_ref<E>>&&
ReceiveError<Out, E>) ReceiveError<Out, E>)void submit(Out out) {
void submit(Out out) {
// queue for later // queue for later
std::unique_lock<std::mutex> guard{queue_->lock_}; std::unique_lock<std::mutex> guard{queue_->lock_};
queue_->items_.push(any_receiver<E, any_executor_ref<E>>{std::move(out)}); queue_->items_.push(any_receiver<E, any_executor_ref<E>>{std::move(out)});
...@@ -241,14 +240,14 @@ class same_executor_factory_fn { ...@@ -241,14 +240,14 @@ class same_executor_factory_fn {
PUSHMI_TEMPLATE(class E = std::exception_ptr, class ExecutorFactory) PUSHMI_TEMPLATE(class E = std::exception_ptr, class ExecutorFactory)
(requires Invocable<ExecutorFactory&>&& (requires Invocable<ExecutorFactory&>&&
Executor<invoke_result_t<ExecutorFactory&>>&& ConcurrentSequence< Executor<invoke_result_t<ExecutorFactory&>>&&
invoke_result_t<ExecutorFactory&>>) ConcurrentSequence<invoke_result_t<ExecutorFactory&>>) //
auto strands(ExecutorFactory ef) { auto strands(ExecutorFactory ef) {
return strand_executor_factory_fn<E, ExecutorFactory>{std::move(ef)}; return strand_executor_factory_fn<E, ExecutorFactory>{std::move(ef)};
} }
PUSHMI_TEMPLATE(class E = std::exception_ptr, class Exec) PUSHMI_TEMPLATE(class E = std::exception_ptr, class Exec)
(requires Executor<Exec>&& ConcurrentSequence<Exec>) (requires Executor<Exec>&& ConcurrentSequence<Exec>) //
auto strands(Exec ex) { auto strands(Exec ex) {
return strand_executor_factory_fn<E, same_executor_factory_fn<Exec>>{ return strand_executor_factory_fn<E, same_executor_factory_fn<Exec>>{
same_executor_factory_fn<Exec>{std::move(ex)}}; same_executor_factory_fn<Exec>{std::move(ex)}};
} }
......
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