proxygen
defer.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 namespace operators {
27 
28 PUSHMI_INLINE_VAR constexpr struct defer_fn {
29  private:
30  template <class F>
31  struct impl {
32  F f_;
33  PUSHMI_TEMPLATE(class Data, class Out)
34  (requires Receiver<Out>)
35  void operator()(Data&, Out out) {
36  auto sender = f_();
37  submit(sender, std::move(out));
38  }
39  };
40 
41  public:
42  PUSHMI_TEMPLATE(class F)
43  (requires Invocable<F&>)
44  auto operator()(F f) const {
45  struct sender_base : single_sender<> {
46  using properties = properties_t<invoke_result_t<F&>>;
47  };
48  return make_single_sender(sender_base{}, impl<F>{std::move(f)});
49  }
50 } defer{};
51 
52 } // namespace operators
53 
54 } // namespace pushmi
55 } // namespace folly
PUSHMI_INLINE_VAR constexpr detail::submit_fn submit
Definition: submit.h:386
auto f
std::enable_if_t< PropertySet< __properties_t< property_set_traits< T >>>, __properties_t< property_set_traits< T >>> properties_t
Definition: properties.h:105
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::operators::defer_fn defer
#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
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::make_single_sender_fn make_single_sender