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