proxygen
time_single_sender.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
22 
23 namespace folly {
24 namespace pushmi {
25 
26 template <class E, class TP, class... VN>
27 class any_time_single_sender
28  : public any_constrained_single_sender<E, TP, VN...> {
29  public:
31  constexpr any_time_single_sender() = default;
32  template <class T>
33  constexpr explicit any_time_single_sender(T t)
34  : any_constrained_single_sender<E, TP, VN...>(std::move(t)) {}
35  template <class T0, class T1, class... TN>
36  constexpr any_time_single_sender(T0 t0, T1 t1, TN... tn)
37  : any_constrained_single_sender<E, TP, VN...>(
38  std::move(t0),
39  std::move(t1),
40  std::move(tn)...) {}
41 
45  }
46 };
47 
48 template <class SF, class NF, class EXF>
49 class time_single_sender<SF, NF, EXF>
50  : public constrained_single_sender<SF, NF, EXF> {
51  public:
53 
54  constexpr time_single_sender() = default;
55  template <class T>
56  constexpr explicit time_single_sender(T t)
57  : constrained_single_sender<SF, NF, EXF>(std::move(t)) {}
58  template <class T0, class T1, class... TN>
59  constexpr time_single_sender(T0 t0, T1 t1, TN... tn)
60  : constrained_single_sender<SF, NF, EXF>(
61  std::move(t0),
62  std::move(t1),
63  std::move(tn)...) {}
64 };
65 
66 template <PUSHMI_TYPE_CONSTRAINT(SemiMovable)... TN>
67 class time_single_sender : public constrained_single_sender<TN...> {
68  public:
69  constexpr time_single_sender() = default;
70  template <class T>
71  constexpr explicit time_single_sender(T t)
72  : constrained_single_sender<TN...>(std::move(t)) {}
73  template <class C0, class C1, class... CN>
74  constexpr time_single_sender(C0 c0, C1 c1, CN... cn)
76  std::move(c0),
77  std::move(c1),
78  std::move(cn)...) {}
79 };
80 
81 template <>
83  : public time_single_sender<ignoreSF, systemNowF, inlineTimeEXF> {
84  public:
85  time_single_sender() = default;
86 };
87 
89 // make_time_single_sender
91  inline auto operator()() const {
93  }
94  PUSHMI_TEMPLATE(class SF)
95  (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
96  auto operator()(SF sf) const {
98  }
99  PUSHMI_TEMPLATE (class SF, class EXF)
100  (requires Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
101  auto operator()(SF sf, EXF exf) const {
103  std::move(sf), std::move(exf)};
104  }
105  PUSHMI_TEMPLATE (class SF, class NF, class EXF)
106  (requires Invocable<NF&> && Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
107  auto operator()(SF sf, EXF exf, NF nf) const {
109  std::move(sf), std::move(exf), std::move(nf)};
110  }
111  PUSHMI_TEMPLATE (class Data)
112  (requires TimeSender<Data, is_single<>>)
113  auto operator()(Data d) const {
115  }
116  PUSHMI_TEMPLATE (class Data, class DSF)
117  (requires TimeSender<Data, is_single<>>)
118  auto operator()(Data d, DSF sf) const {
120  std::move(d), std::move(sf)};
121  }
122  PUSHMI_TEMPLATE (class Data, class DSF, class DEXF)
123  (requires TimeSender<Data, is_single<>> && Invocable<DEXF&, Data&>)
124  auto operator()(Data d, DSF sf, DEXF exf) const {
126  std::move(d), std::move(sf), std::move(exf)};
127  }
128  PUSHMI_TEMPLATE (class Data, class DSF, class DNF, class DEXF)
129  (requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&> &&
130  Invocable<DEXF&, Data&>)
131  auto operator()(Data d, DSF sf, DEXF exf, DNF nf) const {
133  std::move(d), std::move(sf), std::move(exf), std::move(nf)};
134  }
135 } const make_time_single_sender {};
136 
138 // deduction guides
139 #if __cpp_deduction_guides >= 201703
141 
142 PUSHMI_TEMPLATE(class SF)
143  (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
145 
146 PUSHMI_TEMPLATE (class SF, class EXF)
147  (requires Invocable<EXF&> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
149 
150 PUSHMI_TEMPLATE (class SF, class NF, class EXF)
151  (requires Invocable<NF&> && Invocable<EXF&>
152  PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
154 
155 PUSHMI_TEMPLATE (class Data, class DSF)
156  (requires TimeSender<Data, is_single<>>)
157 time_single_sender(Data, DSF) ->
159 
160 PUSHMI_TEMPLATE (class Data, class DSF, class DEXF)
161  (requires TimeSender<Data, is_single<>> && Invocable<DEXF&, Data&>)
162 time_single_sender(Data, DSF, DEXF) ->
164 
165 PUSHMI_TEMPLATE (class Data, class DSF, class DNF, class DEXF)
166  (requires TimeSender<Data, is_single<>> && Invocable<DNF&, Data&> &&
167  Invocable<DEXF&, Data&>)
168 time_single_sender(Data, DSF, DEXF, DNF) ->
170 #endif
171 
172 template<>
175 
176 } // namespace pushmi
177 } // namespace folly
std::true_type True
Definition: TypeList.h:82
requires Tuple && t
constexpr time_single_sender(T0 t0, T1 t1, TN...tn)
constexpr any_time_single_sender()=default
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
folly::std T
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
constexpr any_time_single_sender(T0 t0, T1 t1, TN...tn)
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::make_time_single_sender_fn make_time_single_sender
constexpr time_single_sender(C0 c0, C1 c1, CN...cn)
#define PUSHMI_INLINE_VAR
Definition: concept_def.h:60
requires requires(detail::apply_impl(std::declval< F >(), std::declval< Tuple >(), detail::tupidxs< Tuple >{}))) const expr decltype(auto) apply(F &&f
PUSHMI_TEMPLATE(class E=std::exception_ptr, class Wrapped)(requires Sender< detail
Definition: executor.h:102
any_time_executor< E, TP > executor()
#define PUSHMI_TYPE_CONSTRAINT(...)
Definition: concept_def.h:420
#define PUSHMI_BROKEN_SUBSUMPTION(...)
Definition: concept_def.h:419