proxygen
Future-pre.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-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 
18 // included by Future.h, do not include directly.
19 
20 namespace folly {
21 
22 template <class>
23 class Promise;
24 
25 template <class T>
26 class SemiFuture;
27 
28 template <typename T>
30  using Inner = typename lift_unit<T>::type;
31 };
32 
33 template <typename T>
35  typedef T Inner;
36 };
37 
38 template <typename T>
40  using Inner = typename lift_unit<T>::type;
41 };
42 
43 template <typename T>
45  typedef T Inner;
46 };
47 
48 template <typename T>
50  using Inner = typename lift_unit<T>::type;
51  using Return = Inner;
52 };
53 
54 template <typename T>
56  typedef T Inner;
58 };
59 
60 template <typename T>
62  typedef T Inner;
64 };
65 
66 template <typename T>
67 struct isTry : std::false_type {};
68 
69 template <typename T>
70 struct isTry<Try<T>> : std::true_type {};
71 
72 namespace futures {
73 namespace detail {
74 
75 template <class>
76 class Core;
77 
78 template <typename...>
79 struct ArgType;
80 
81 template <typename Arg, typename... Args>
82 struct ArgType<Arg, Args...> {
83  typedef Arg FirstArg;
84 };
85 
86 template <>
87 struct ArgType<> {
88  typedef void FirstArg;
89 };
90 
91 template <bool isTry_, typename F, typename... Args>
92 struct argResult {
93  using Function = F;
94  using ArgList = ArgType<Args...>;
95  using Result = invoke_result_t<F, Args...>;
96  using ArgsSize = index_constant<sizeof...(Args)>;
97  static constexpr bool isTry() {
98  return isTry_;
99  }
100 };
101 
102 template <typename T, typename F>
104  typedef typename std::conditional<
107  typename std::conditional<
113 };
114 
115 template <typename T, typename F>
121 };
122 
123 template <typename T, typename F>
128  typedef typename Arg::ArgList::FirstArg FirstArg;
130 };
131 
132 template <typename L>
133 struct Extract : Extract<decltype(&L::operator())> {};
134 
135 template <typename Class, typename R, typename... Args>
136 struct Extract<R (Class::*)(Args...) const> {
139  typedef typename ReturnsFuture::Inner RawReturn;
140  typedef typename ArgType<Args...>::FirstArg FirstArg;
141 };
142 
143 template <typename Class, typename R, typename... Args>
144 struct Extract<R (Class::*)(Args...)> {
147  typedef typename ReturnsFuture::Inner RawReturn;
148  typedef typename ArgType<Args...>::FirstArg FirstArg;
149 };
150 
151 template <typename R, typename... Args>
152 struct Extract<R (*)(Args...)> {
155  typedef typename ReturnsFuture::Inner RawReturn;
156  typedef typename ArgType<Args...>::FirstArg FirstArg;
157 };
158 
159 template <typename R, typename... Args>
160 struct Extract<R (&)(Args...)> {
163  typedef typename ReturnsFuture::Inner RawReturn;
164  typedef typename ArgType<Args...>::FirstArg FirstArg;
165 };
166 
167 class DeferredExecutor;
168 
169 } // namespace detail
170 } // namespace futures
171 
172 class Timekeeper;
173 
174 } // namespace folly
isFutureOrSemiFuture< typename Arg::Result > ReturnsFuture
Definition: Future-pre.h:111
isFutureOrSemiFuture< typename Arg::Result > ReturnsFuture
Definition: Future-pre.h:126
A polymorphic function wrapper that is not copyable and does not require the wrapped function to be c...
typename invoke_result< F, Args... >::type invoke_result_t
Definition: Invoke.h:142
detail::argResult< true, F, Try< T > && > Arg
Definition: Future-pre.h:117
PskType type
std::integral_constant< std::size_t, I > index_constant
Definition: Traits.h:150
folly::std T
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
Future< typename ReturnsFuture::Inner > Return
Definition: Future-pre.h:162
bool_constant< true > true_type
Definition: gtest-port.h:2210
typename lift_unit< T >::type Inner
Definition: Future-pre.h:40
Future< typename ReturnsFuture::Inner > Return
Definition: Future-pre.h:154
Future< typename ReturnsFuture::Inner > Return
Definition: Future-pre.h:146
typename lift_unit< T >::type Inner
Definition: Future-pre.h:30
std::conditional< is_invocable< F >::value, detail::argResult< false, F >, typename std::conditional< is_invocable< F, T && >::value, detail::argResult< false, F, T && >, detail::argResult< true, F, Try< T > && > >::type >::type Arg
Definition: Future-pre.h:110
ArgType< Args... >::FirstArg FirstArg
Definition: Future-pre.h:156
Definition: Try.h:51
isFutureOrSemiFuture< typename Arg::Result > ReturnsFuture
Definition: Future-pre.h:118
Future< typename ReturnsFuture::Inner > Return
Definition: Future-pre.h:112
detail::argResult< false, F, T && > Arg
Definition: Future-pre.h:125
const
Definition: upload.py:398
bool_constant< false > false_type
Definition: gtest-port.h:2209
static constexpr bool isTry()
Definition: Future-pre.h:97
index_constant< sizeof...(Args)> ArgsSize
Definition: Future-pre.h:96
typename lift_unit< T >::type Inner
Definition: Future-pre.h:50
invoke_result_t< F, Args... > Result
Definition: Future-pre.h:95
ArgType< Args... >::FirstArg FirstArg
Definition: Future-pre.h:164
Future< typename ReturnsFuture::Inner > Return
Definition: Future-pre.h:138