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

STEllAR-GROUP / hpx / #849

08 Dec 2022 10:31PM UTC coverage: 85.715% (-0.7%) from 86.456%
#849

push

StellarBot
Merge #6102

6102: Prevent warnings generated by clang-cl r=hkaiser a=hkaiser

clang-cl does not support `[[no_unique_address]]` nor does it support `[[msvc::no_unique_address]]`. This PR fixes the related warning generated by it.

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

171602 of 200200 relevant lines covered (85.72%)

2048410.46 hits per line

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

12.77
/libs/full/async_colocated/tests/unit/async_continue_cb_colocated.cpp
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
#include <hpx/config.hpp>
8
#if !defined(HPX_COMPUTE_DEVICE_CODE)
9
#include <hpx/hpx_init.hpp>
10
#include <hpx/include/async.hpp>
11
#include <hpx/include/components.hpp>
12
#include <hpx/include/lcos.hpp>
13
#include <hpx/include/post.hpp>
14
#include <hpx/include/runtime.hpp>
15
#include <hpx/modules/testing.hpp>
16

17
#include <atomic>
18
#include <chrono>
19
#include <cstdint>
20
#include <system_error>
21
#include <utility>
22
#include <vector>
23

24
///////////////////////////////////////////////////////////////////////////////
25
std::int32_t increment(std::int32_t i)
7✔
26
{
27
    return i + 1;
7✔
28
}
29
HPX_PLAIN_ACTION(increment)    // defines increment_action
10✔
30

31
std::int32_t increment_with_future(hpx::shared_future<std::int32_t> fi)
2✔
32
{
33
    return fi.get() + 1;
2✔
34
}
35
HPX_PLAIN_ACTION(increment_with_future)
5✔
36

37
///////////////////////////////////////////////////////////////////////////////
38
std::int32_t mult2(std::int32_t i)
×
39
{
40
    return i * 2;
×
41
}
42
HPX_PLAIN_ACTION(mult2)    // defines mult2_action
14✔
43

44
///////////////////////////////////////////////////////////////////////////////
45
struct test_server : hpx::components::component_base<test_server>
2✔
46
{
47
};
48

49
typedef hpx::components::component<test_server> test_server_type;
50
HPX_REGISTER_COMPONENT(test_server_type, test_server)
28✔
51

52
struct test_client : hpx::components::client_base<test_client, test_server>
×
53
{
54
    typedef hpx::components::client_base<test_client, test_server> base_type;
55

56
    test_client(hpx::id_type const& id)
×
57
      : base_type(id)
×
58
    {
×
59
    }
×
60
    test_client(hpx::future<hpx::id_type>&& id)
×
61
      : base_type(std::move(id))
×
62
    {
×
63
    }
×
64
};
65

66
///////////////////////////////////////////////////////////////////////////////
67
std::atomic<int> callback_called(0);
68

69
#if defined(HPX_HAVE_NETWORKING)
70
void cb(std::error_code const&, hpx::parcelset::parcel const&)
×
71
{
72
    ++callback_called;
×
73
}
×
74
#else
75
void cb()
76
{
77
    ++callback_called;
78
}
79
#endif
80

81
///////////////////////////////////////////////////////////////////////////////
82
int test_async_continue_cb_colocated(test_client const& target)
×
83
{
84
    using hpx::make_continuation;
85

86
    increment_action inc;
87
    increment_with_future_action inc_f;
88
    mult2_action mult;
89

90
    // test locally, fully equivalent to plain hpx::async
91
    {
92
        callback_called.store(0);
×
93
        hpx::future<int> f1 = hpx::async_continue_cb(
×
94
            inc, make_continuation(), hpx::colocated(target), &cb, 42);
×
95
        HPX_TEST_EQ(f1.get(), 43);
×
96

97
        hpx::distributed::promise<std::int32_t> p;
×
98
        hpx::shared_future<std::int32_t> f = p.get_future();
×
99

100
        hpx::future<int> f2 = hpx::async_continue_cb(
×
101
            inc_f, make_continuation(), hpx::colocated(target), &cb, f);
×
102

103
        p.set_value(42);
×
104
        HPX_TEST_EQ(f2.get(), 43);
×
105

106
        // The callback should have been called 2 times. wait for a short period
107
        // of time, to allow it for it to be fully executed
108
        hpx::this_thread::sleep_for(std::chrono::milliseconds(100));
×
109
        HPX_TEST_EQ(callback_called.load(), 2);
×
110
    }
×
111

112
    {
113
        callback_called.store(0);
×
114
        hpx::future<int> f1 = hpx::async_continue_cb(
×
115
            inc, make_continuation(), hpx::colocated(target), &cb, 42);
×
116
        HPX_TEST_EQ(f1.get(), 43);
×
117
        hpx::this_thread::sleep_for(std::chrono::milliseconds(100));
×
118
        HPX_TEST_EQ(callback_called.load(), 1);
×
119

120
        hpx::distributed::promise<std::int32_t> p;
×
121
        hpx::shared_future<std::int32_t> f = p.get_future();
×
122

123
        hpx::future<int> f2 = hpx::async_continue_cb(
×
124
            inc_f, make_continuation(), hpx::colocated(target), &cb, f);
×
125

126
        p.set_value(42);
×
127
        HPX_TEST_EQ(f2.get(), 43);
×
128

129
        // The callback should have been called 2 times. wait for a short period
130
        // of time, to allow for it to be fully executed
131
        hpx::this_thread::sleep_for(std::chrono::milliseconds(100));
×
132
        HPX_TEST_EQ(callback_called.load(), 2);
×
133
    }
×
134

135
    // test chaining locally
136
    {
137
        callback_called.store(0);
×
138
        hpx::future<int> f = hpx::async_continue_cb(
×
139
            inc, make_continuation(mult), hpx::colocated(target), &cb, 42);
×
140
        HPX_TEST_EQ(f.get(), 86);
×
141

142
        f = hpx::async_continue_cb(inc,
×
143
            make_continuation(mult, make_continuation()),
×
144
            hpx::colocated(target), &cb, 42);
×
145
        HPX_TEST_EQ(f.get(), 86);
×
146

147
        f = hpx::async_continue_cb(inc,
×
148
            make_continuation(mult, make_continuation(inc)),
×
149
            hpx::colocated(target), &cb, 42);
×
150
        HPX_TEST_EQ(f.get(), 87);
×
151

152
        f = hpx::async_continue_cb(inc,
×
153
            make_continuation(
×
154
                mult, make_continuation(inc, make_continuation())),
×
155
            hpx::colocated(target), &cb, 42);
×
156
        HPX_TEST_EQ(f.get(), 87);
×
157

158
        // The callback should have been called 4 times. wait for a short period
159
        // of time, to allow for it to be fully executed
160
        hpx::this_thread::sleep_for(std::chrono::milliseconds(100));
×
161
        HPX_TEST_EQ(callback_called.load(), 4);
×
162
    }
×
163

164
    // test chaining
165
    {
166
        //         callback_called.store(0);
167
        //         hpx::future<int> f = hpx::async_continue_cb(inc,
168
        //             make_continuation(mult, hpx::colocated(target)),
169
        //             hpx::colocated(target), &cb, 42);
170
        //         HPX_TEST_EQ(f.get(), 86);
171
        //         HPX_TEST_EQ(callback_called.load(), 1);
172
        //
173
        //         callback_called.store(0);
174
        //         f = hpx::async_continue_cb(inc,
175
        //             make_continuation(mult, hpx::colocated(target),
176
        //                 make_continuation()),
177
        //             hpx::colocated(target), &cb, 42);
178
        //         HPX_TEST_EQ(f.get(), 86);
179
        //         HPX_TEST_EQ(callback_called.load(), 1);
180
        //
181
        //         callback_called.store(0);
182
        //         f = hpx::async_continue_cb(inc,
183
        //             make_continuation(mult, hpx::colocated(target),
184
        //                 make_continuation(inc)), hpx::colocated(target), &cb, 42);
185
        //         HPX_TEST_EQ(f.get(), 87);
186
        //         HPX_TEST_EQ(callback_called.load(), 1);
187
        //
188
        //         callback_called.store(0);
189
        //         f = hpx::async_continue_cb(inc,
190
        //             make_continuation(mult, hpx::colocated(target),
191
        //                 make_continuation(inc, make_continuation())),
192
        //                 hpx::colocated(target),
193
        //             &cb, 42);
194
        //         HPX_TEST_EQ(f.get(), 87);
195
        //         HPX_TEST_EQ(callback_called.load(), 1);
196
        //
197
        //         callback_called.store(0);
198
        //         f = hpx::async_continue_cb(inc,
199
        //             make_continuation(mult, hpx::colocated(target),
200
        //                 make_continuation(inc, hpx::colocated(target))),
201
        //                 hpx::colocated(target), &cb, 42);
202
        //         HPX_TEST_EQ(f.get(), 87);
203
        //         HPX_TEST_EQ(callback_called.load(), 1);
204
        //
205
        //         callback_called.store(0);
206
        //         f = hpx::async_continue_cb(inc,
207
        //             make_continuation(mult, hpx::colocated(target),
208
        //                 make_continuation(inc, hpx::colocated(target),
209
        //                 make_continuation())),
210
        //                 hpx::colocated(target), &cb, 42);
211
        //         HPX_TEST_EQ(f.get(), 87);
212
        //         HPX_TEST_EQ(callback_called.load(), 1);
213
        //
214
        //         callback_called.store(0);
215
        //         f = hpx::async_continue_cb(inc,
216
        //             make_continuation(mult), hpx::colocated(target), &cb, 42);
217
        //         HPX_TEST_EQ(f.get(), 86);
218
        //         HPX_TEST_EQ(callback_called.load(), 1);
219

220
        callback_called.store(0);
×
221
        hpx::future<int> f = hpx::async_continue_cb(inc,
×
222
            make_continuation(mult, make_continuation()),
×
223
            hpx::colocated(target), &cb, 42);
×
224
        HPX_TEST_EQ(f.get(), 86);
×
225

226
        // The callback should have been called once. wait for a short period
227
        // of time, to allow for it to be fully executed
228
        hpx::this_thread::sleep_for(std::chrono::milliseconds(100));
×
229
        HPX_TEST_EQ(callback_called.load(), 1);
×
230
    }
×
231

232
    return hpx::finalize();
×
233
}
×
234

235
int hpx_main()
×
236
{
237
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
238
    for (hpx::id_type const& id : localities)
×
239
    {
240
        test_client client(hpx::new_<test_client>(id));
×
241
        test_async_continue_cb_colocated(client);
×
242
    }
×
243
    return hpx::finalize();
×
244
}
×
245

246
int main(int argc, char* argv[])
1✔
247
{
248
    // Initialize and run HPX
249
    HPX_TEST_EQ_MSG(
1✔
250
        hpx::init(argc, argv), 0, "HPX main exited with non-zero status");
251

252
    return hpx::util::report_errors();
1✔
253
}
×
254
#endif
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