• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #872

24 Jan 2023 07:29PM UTC coverage: 85.694% (-0.9%) from 86.624%
#872

push

StellarBot
Merge #6148

6148: Investigate the failure of the LCI parcelport. r=hkaiser a=JiakunYan



Co-authored-by: Jiakun Yan <jiakunyan1998@gmail.com>

173076 of 201969 relevant lines covered (85.69%)

2110584.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.42
/libs/full/async_distributed/include/hpx/async_distributed/async_callback.hpp
1
//  Copyright (c) 2007-2015 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#pragma once
8

9
#include <hpx/config.hpp>
10
#include <hpx/actions_base/traits/extract_action.hpp>
11
#include <hpx/actions_base/traits/is_client.hpp>
12
#include <hpx/actions_base/traits/is_distribution_policy.hpp>
13
#include <hpx/actions_base/traits/is_valid_action.hpp>
14
#include <hpx/async_base/launch_policy.hpp>
15
#include <hpx/async_base/traits/is_launch_policy.hpp>
16
#include <hpx/async_distributed/async_callback_fwd.hpp>
17
#include <hpx/async_distributed/detail/async_implementations_fwd.hpp>
18
#include <hpx/components/client_base.hpp>
19
#include <hpx/functional/traits/is_action.hpp>
20
#include <hpx/futures/future.hpp>
21
#include <hpx/futures/traits/promise_local_result.hpp>
22

23
#include <type_traits>
24
#include <utility>
25

26
///////////////////////////////////////////////////////////////////////////////
27
namespace hpx { namespace detail {
28
    // launch
29
    template <typename Action, typename Policy>
30
    struct async_cb_action_dispatch<Action, Policy,
31
        typename std::enable_if<traits::is_launch_policy<Policy>::value>::type>
32
    {
33
        // id_type
34
        template <typename Policy_, typename Callback, typename... Ts>
35
        HPX_FORCEINLINE static hpx::future<
36
            typename traits::promise_local_result<typename traits::
37
                    extract_action<Action>::remote_result_type>::type>
38
        call(Policy_&& launch_policy, hpx::id_type const& id, Callback&& cb,
6✔
39
            Ts&&... ts)
40
        {
41
            return hpx::detail::async_cb_impl<Action>(
6✔
42
                HPX_FORWARD(Policy_, launch_policy), id,
6✔
43
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
6✔
44
        }
45

46
        template <typename Policy_, typename Client, typename Stub,
47
            typename Callback, typename... Ts>
48
        HPX_FORCEINLINE static hpx::future<
49
            typename traits::promise_local_result<typename traits::
50
                    extract_action<Action>::remote_result_type>::type>
51
        call(Policy_&& launch_policy,
4✔
52
            components::client_base<Client, Stub> const& c, Callback&& cb,
53
            Ts&&... ts)
54
        {
55
            typedef typename components::client_base<Client,
56
                Stub>::server_component_type component_type;
57

58
            typedef traits::is_valid_action<Action, component_type> is_valid;
59
            static_assert(is_valid::value,
60
                "The action to invoke is not supported by the target");
61

62
            return hpx::detail::async_cb_impl<Action>(
4✔
63
                HPX_FORWARD(Policy_, launch_policy), c.get_id(),
4✔
64
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
4✔
65
        }
66

67
        // distribution policy
68
        template <typename Policy_, typename DistPolicy, typename Callback,
69
            typename... Ts>
70
        HPX_FORCEINLINE static typename std::enable_if<
71
            traits::is_distribution_policy<DistPolicy>::value,
72
            hpx::future<typename traits::promise_local_result<typename traits::
73
                    extract_action<Action>::remote_result_type>::type>>::type
74
        call(Policy_&& launch_policy, DistPolicy const& policy, Callback&& cb,
×
75
            Ts&&... ts)
76
        {
77
            return policy.template async_cb<Action>(
×
78
                HPX_FORWARD(Policy_, launch_policy), HPX_FORWARD(Callback, cb),
×
79
                HPX_FORWARD(Ts, ts)...);
×
80
        }
81
    };
82

83
    // hpx::id_type
84
    template <typename Action>
85
    struct async_cb_action_dispatch<Action, hpx::id_type>
86
    {
87
        template <typename Callback, typename... Ts>
88
        HPX_FORCEINLINE static hpx::future<
89
            typename traits::promise_local_result<typename traits::
90
                    extract_action<Action>::remote_result_type>::type>
91
        call(hpx::id_type const& id, Callback&& cb, Ts&&... ts)
2✔
92
        {
93
            return async_cb_action_dispatch<Action,
2✔
94
                hpx::detail::async_policy>::call(launch::async, id,
2✔
95
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
2✔
96
        }
97
    };
98

99
    // component::client
100
    template <typename Action, typename Client>
101
    struct async_cb_action_dispatch<Action, Client,
102
        typename std::enable_if<traits::is_client<Client>::value>::type>
103
    {
104
        template <typename Client_, typename Stub, typename Callback,
105
            typename... Ts>
106
        HPX_FORCEINLINE static hpx::future<
107
            typename traits::promise_local_result<typename traits::
108
                    extract_action<Action>::remote_result_type>::type>
109
        call(components::client_base<Client_, Stub> const& c, Callback&& cb,
4✔
110
            Ts&&... ts)
111
        {
112
            typedef typename components::client_base<Client_,
113
                Stub>::server_component_type component_type;
114

115
            typedef traits::is_valid_action<Action, component_type> is_valid;
116
            static_assert(is_valid::value,
117
                "The action to invoke is not supported by the target");
118

119
            return async_cb_action_dispatch<Action,
4✔
120
                hpx::detail::async_policy>::call(launch::async, c.get_id(),
4✔
121
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
4✔
122
        }
123
    };
124

125
    // distribution policy
126
    template <typename Action, typename Policy>
127
    struct async_cb_action_dispatch<Action, Policy,
128
        typename std::enable_if<
129
            traits::is_distribution_policy<Policy>::value>::type>
130
    {
131
        template <typename DistPolicy, typename Callback, typename... Ts>
132
        HPX_FORCEINLINE static hpx::future<
133
            typename traits::promise_local_result<typename traits::
134
                    extract_action<Action>::remote_result_type>::type>
135
        call(DistPolicy const& policy, Callback&& cb, Ts&&... ts)
×
136
        {
137
            return async_cb_action_dispatch<Action,
×
138
                hpx::detail::async_policy>::call(launch::async, policy,
×
139
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
×
140
        }
141
    };
142
}}    // namespace hpx::detail
143

144
namespace hpx {
145
    template <typename Action, typename F, typename... Ts>
146
    HPX_FORCEINLINE auto async_cb(F&& f, Ts&&... ts)
10✔
147
        -> decltype(detail::async_cb_action_dispatch<Action,
148
            typename std::decay<F>::type>::call(HPX_FORWARD(F, f),
149
            HPX_FORWARD(Ts, ts)...))
150
    {
151
        return detail::async_cb_action_dispatch<Action,
10✔
152
            typename std::decay<F>::type>::call(HPX_FORWARD(F, f),
10✔
153
            HPX_FORWARD(Ts, ts)...);
10✔
154
    }
155
}    // namespace hpx
156

157
///////////////////////////////////////////////////////////////////////////////
158
namespace hpx { namespace detail {
159
    // any action
160
    template <typename Action>
161
    struct async_cb_dispatch<Action,
162
        typename std::enable_if<traits::is_action<Action>::value>::type>
163
    {
164
        template <typename Component, typename Signature, typename Derived,
165
            typename Callback, typename... Ts>
166
        HPX_FORCEINLINE static hpx::future<
167
            typename traits::promise_local_result<typename traits::
168
                    extract_action<Derived>::remote_result_type>::type>
169
        call(hpx::actions::basic_action<Component, Signature, Derived> const&,
2✔
170
            hpx::id_type const& id, Callback&& cb, Ts&&... ts)
171
        {
172
            return async_cb<Derived>(
2✔
173
                id, HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
2✔
174
        }
175

176
        template <typename Component, typename Signature, typename Derived,
177
            typename Client, typename Stub, typename Callback, typename... Ts>
178
        HPX_FORCEINLINE static hpx::future<
179
            typename traits::promise_local_result<typename traits::
180
                    extract_action<Derived>::remote_result_type>::type>
181
        call(hpx::actions::basic_action<Component, Signature, Derived> const&,
182
            components::client_base<Client, Stub> const& c, Callback&& cb,
183
            Ts&&... ts)
184
        {
185
            typedef typename components::client_base<Client,
186
                Stub>::server_component_type component_type;
187

188
            typedef traits::is_valid_action<Derived, component_type> is_valid;
189
            static_assert(is_valid::value,
190
                "The action to invoke is not supported by the target");
191

192
            return async_cb<Derived>(
193
                c.get_id(), HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
194
        }
195

196
        template <typename Component, typename Signature, typename Derived,
197
            typename DistPolicy, typename Callback, typename... Ts>
198
        HPX_FORCEINLINE static hpx::future<
199
            typename traits::promise_local_result<typename traits::
200
                    extract_action<Derived>::remote_result_type>::type>
201
        call(hpx::actions::basic_action<Component, Signature, Derived> const&,
2✔
202
            DistPolicy const& policy, Callback&& cb, Ts&&... ts)
203
        {
204
            return async_cb<Derived>(
2✔
205
                policy, HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
2✔
206
        }
207
    };
208

209
    template <typename Policy>
210
    struct async_cb_dispatch<Policy,
211
        typename std::enable_if<traits::is_launch_policy<Policy>::value>::type>
212
    {
213
        template <typename Policy_, typename Component, typename Signature,
214
            typename Derived, typename Callback, typename... Ts>
215
        HPX_FORCEINLINE static hpx::future<
216
            typename traits::promise_local_result<typename traits::
217
                    extract_action<Derived>::remote_result_type>::type>
218
        call(Policy_&& launch_policy,
×
219
            hpx::actions::basic_action<Component, Signature, Derived> const&,
220
            hpx::id_type const& id, Callback&& cb, Ts&&... ts)
221
        {
222
            return async_cb<Derived>(HPX_FORWARD(Policy_, launch_policy), id,
×
223
                HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
×
224
        }
225

226
        template <typename Policy_, typename Component, typename Signature,
227
            typename Derived, typename Client, typename Stub, typename Callback,
228
            typename... Ts>
229
        HPX_FORCEINLINE static hpx::future<
230
            typename traits::promise_local_result<typename traits::
231
                    extract_action<Derived>::remote_result_type>::type>
232
        call(Policy_&& launch_policy,
233
            hpx::actions::basic_action<Component, Signature, Derived> const&,
234
            components::client_base<Client, Stub> const& c, Callback&& cb,
235
            Ts&&... ts)
236
        {
237
            typedef typename components::client_base<Client,
238
                Stub>::server_component_type component_type;
239

240
            typedef traits::is_valid_action<Derived, component_type> is_valid;
241
            static_assert(is_valid::value,
242
                "The action to invoke is not supported by the target");
243

244
            return async_cb<Derived>(HPX_FORWARD(Policy_, launch_policy),
245
                c.get_id(), HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
246
        }
247

248
        template <typename Policy_, typename Component, typename Signature,
249
            typename Derived, typename DistPolicy, typename Callback,
250
            typename... Ts>
251
        HPX_FORCEINLINE static hpx::future<
252
            typename traits::promise_local_result<typename traits::
253
                    extract_action<Derived>::remote_result_type>::type>
254
        call(Policy_&& launch_policy,
2✔
255
            hpx::actions::basic_action<Component, Signature, Derived> const&,
256
            DistPolicy const& policy, Callback&& cb, Ts&&... ts)
257
        {
258
            return async_cb<Derived>(HPX_FORWARD(Policy_, launch_policy),
4✔
259
                policy, HPX_FORWARD(Callback, cb), HPX_FORWARD(Ts, ts)...);
2✔
260
        }
261
    };
262
}}    // namespace hpx::detail
263

264
namespace hpx {
265
    template <typename F, typename... Ts>
266
    HPX_FORCEINLINE auto async_cb(F&& f, Ts&&... ts) -> decltype(
6✔
267
        detail::async_cb_dispatch<typename std::decay<F>::type>::call(
268
            HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...))
269
    {
270
        return detail::async_cb_dispatch<typename std::decay<F>::type>::call(
6✔
271
            HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...);
6✔
272
    }
273
}    // namespace hpx
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc