proxygen
switch_on_error.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 
20 
21 namespace folly {
22 namespace pushmi {
23 
24 namespace detail {
25 
27  private:
28  template <class ErrorSelector>
29  struct on_error_impl {
30  ErrorSelector es_;
31  PUSHMI_TEMPLATE(class Out, class E)
32  (requires Receiver<Out>&& Invocable<const ErrorSelector&, E>&&
33  SenderTo<::folly::pushmi::invoke_result_t<ErrorSelector&, E>, Out>)
34  void operator()(Out& out, E&& e) const noexcept {
35  static_assert(
36  ::folly::pushmi::NothrowInvocable<const ErrorSelector&, E>,
37  "switch_on_error - error selector function must be noexcept");
38  auto next = es_((E &&) e);
39  submit(next, out);
40  }
41  };
42  template <class In, class ErrorSelector>
43  struct out_impl {
44  ErrorSelector es_;
45  PUSHMI_TEMPLATE(class Out)
46  (requires Receiver<Out>)
47  auto operator()(Out out) const {
48  return ::folly::pushmi::detail::receiver_from_fn<In>()(
49  std::move(out),
50  // copy 'es' to allow multiple calls to submit
52  }
53  };
54  template <class ErrorSelector>
55  struct in_impl {
56  ErrorSelector es_;
57  PUSHMI_TEMPLATE(class In)
58  (requires Sender<In>)
59  auto operator()(In in) const {
61  std::move(in),
62  ::folly::pushmi::detail::submit_transform_out<In>(
64  }
65  };
66 
67  public:
68  PUSHMI_TEMPLATE(class ErrorSelector)
69  (requires SemiMovable<ErrorSelector>)
70  auto operator()(ErrorSelector es) const {
72  }
73 };
74 
75 } // namespace detail
76 
77 namespace operators {
79 } // namespace operators
80 
81 } // namespace pushmi
82 } // namespace folly
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr detail::switch_on_error_fn switch_on_error
auto on_error(Fns...fns) -> on_error_fn< Fns... >
Definition: boosters.h:273
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
requires requires(::folly::pushmi::invoke(std::declval< F >(), std::get< Is >(std::declval< Tuple >())...))) const expr decltype(auto) apply_impl(F &&f
#define PUSHMI_INLINE_VAR
Definition: concept_def.h:60
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::detail::sender_from_fn sender_from
PUSHMI_INLINE_VAR constexpr __adl::do_submit_fn submit
PUSHMI_TEMPLATE(class In, class Out, bool SenderRequires, bool SingleSenderRequires, bool TimeSingleSenderRequires)(requires Sender< In > &&Receiver< Out >) constexpr bool sender_requires_from()
def next(obj)
Definition: ast.py:58