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

STEllAR-GROUP / hpx / #879

02 Feb 2023 09:18PM UTC coverage: 86.575% (+0.05%) from 86.523%
#879

push

StellarBot
Merge #6161

6161: Update EVE integration r=hkaiser a=srinivasyadav18

## Proposed Changes

  - use new tag for eve fetch content : hpx-v1.9.0
  - delete FindEve.cmake, instead use `find_package(eve)`
  - replace alias `Eve::eve` with `eve::eve`
  - cleanup eve header inclusions

Co-authored-by: srinivasyadav18 <srinivasyadav227@icloud.com>

174856 of 201970 relevant lines covered (86.58%)

1949482.83 hits per line

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

16.28
/libs/full/async_distributed/tests/unit/async_remote.cpp
1
//  Copyright (c) 2007-2017 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/actions.hpp>
11
#include <hpx/include/async.hpp>
12
#include <hpx/include/components.hpp>
13
#include <hpx/include/lcos.hpp>
14
#include <hpx/include/runtime.hpp>
15
#include <hpx/modules/testing.hpp>
16

17
#include <atomic>
18
#include <cstdint>
19
#include <vector>
20

21
///////////////////////////////////////////////////////////////////////////////
22
std::int32_t increment(std::int32_t i)
5✔
23
{
24
    return i + 1;
5✔
25
}
26
HPX_PLAIN_ACTION(increment)
8✔
27

28
std::int32_t increment_with_future(hpx::shared_future<std::int32_t> fi)
6✔
29
{
30
    return fi.get() + 1;
6✔
31
}
32
HPX_PLAIN_ACTION(increment_with_future)
9✔
33

34
///////////////////////////////////////////////////////////////////////////////
35
struct decrement_server
6✔
36
  : hpx::components::managed_component_base<decrement_server>
37
{
38
    std::int32_t call(std::int32_t i) const
7✔
39
    {
40
        return i - 1;
7✔
41
    }
42

43
    HPX_DEFINE_COMPONENT_ACTION(decrement_server, call)
44
};
45

46
typedef hpx::components::managed_component<decrement_server> server_type;
47
HPX_REGISTER_COMPONENT(server_type, decrement_server)
54✔
48

49
typedef decrement_server::call_action call_action;
50
HPX_REGISTER_ACTION_DECLARATION(call_action)
51
HPX_REGISTER_ACTION(call_action)
10✔
52

53
///////////////////////////////////////////////////////////////////////////////
54
void test_remote_async(hpx::id_type const& target)
×
55
{
56
    {
57
        increment_action inc;
58

59
        hpx::future<std::int32_t> f1 = hpx::async(inc, target, 42);
×
60
        HPX_TEST_EQ(f1.get(), 43);
×
61

62
        hpx::future<std::int32_t> f2 =
63
            hpx::async(hpx::launch::all, inc, target, 42);
×
64
        HPX_TEST_EQ(f2.get(), 43);
×
65
    }
×
66

67
    {
68
        increment_with_future_action inc;
69
        hpx::distributed::promise<std::int32_t> p;
×
70
        hpx::shared_future<std::int32_t> f = p.get_future();
×
71

72
        hpx::future<std::int32_t> f1 = hpx::async(inc, target, f);
×
73
        hpx::future<std::int32_t> f2 =
74
            hpx::async(hpx::launch::all, inc, target, f);
×
75

76
        p.set_value(42);
×
77
        HPX_TEST_EQ(f1.get(), 43);
×
78
        HPX_TEST_EQ(f2.get(), 43);
×
79
    }
×
80

81
    {
82
        increment_action inc;
83

84
        hpx::future<std::int32_t> f1 = hpx::async(hpx::bind(inc, target, 42));
×
85
        HPX_TEST_EQ(f1.get(), 43);
×
86
    }
×
87

88
    {
89
        hpx::future<std::int32_t> f1 = hpx::async<increment_action>(target, 42);
×
90
        HPX_TEST_EQ(f1.get(), 43);
×
91

92
        hpx::future<std::int32_t> f2 =
93
            hpx::async<increment_action>(hpx::launch::all, target, 42);
×
94
        HPX_TEST_EQ(f2.get(), 43);
×
95
    }
×
96

97
    {
98
        hpx::future<hpx::id_type> dec_f =
99
            hpx::components::new_<decrement_server>(target);
×
100
        hpx::id_type dec = dec_f.get();
×
101

102
        call_action call;
103

104
        hpx::future<std::int32_t> f1 = hpx::async(call, dec, 42);
×
105
        HPX_TEST_EQ(f1.get(), 41);
×
106

107
        hpx::future<std::int32_t> f2 =
108
            hpx::async(hpx::launch::all, call, dec, 42);
×
109
        HPX_TEST_EQ(f2.get(), 41);
×
110
    }
×
111

112
    {
113
        hpx::future<hpx::id_type> dec_f =
114
            hpx::components::new_<decrement_server>(target);
×
115
        hpx::id_type dec = dec_f.get();
×
116

117
        call_action call;
118

119
        hpx::future<std::int32_t> f1 = hpx::async(hpx::bind(call, dec, 42));
×
120
        HPX_TEST_EQ(f1.get(), 41);
×
121

122
        using hpx::placeholders::_1;
123
        using hpx::placeholders::_2;
124

125
        hpx::future<std::int32_t> f2 = hpx::async(hpx::bind(call, _1, 42), dec);
×
126
        HPX_TEST_EQ(f2.get(), 41);
×
127

128
        hpx::future<std::int32_t> f3 =
129
            hpx::async(hpx::bind(call, _1, _2), dec, 42);
×
130
        HPX_TEST_EQ(f3.get(), 41);
×
131
    }
×
132

133
    {
134
        hpx::future<hpx::id_type> dec_f =
135
            hpx::components::new_<decrement_server>(target);
×
136
        hpx::id_type dec = dec_f.get();
×
137

138
        hpx::future<std::int32_t> f1 = hpx::async<call_action>(dec, 42);
×
139
        HPX_TEST_EQ(f1.get(), 41);
×
140

141
        hpx::future<std::int32_t> f2 =
142
            hpx::async<call_action>(hpx::launch::all, dec, 42);
×
143
        HPX_TEST_EQ(f2.get(), 41);
×
144
    }
×
145

146
    {
147
        increment_with_future_action inc;
148
        hpx::shared_future<std::int32_t> f =
149
            hpx::async(hpx::launch::deferred, hpx::bind(&increment, 42));
×
150

151
        hpx::future<std::int32_t> f1 = hpx::async(inc, target, f);
×
152
        hpx::future<std::int32_t> f2 =
153
            hpx::async(hpx::launch::all, inc, target, f);
×
154

155
        HPX_TEST_EQ(f1.get(), 44);
×
156
        HPX_TEST_EQ(f2.get(), 44);
×
157
    }
×
158

159
    {
160
        auto policy1 =
161
            hpx::launch::select([]() { return hpx::launch::deferred; });
×
162

163
        increment_with_future_action inc;
164
        hpx::shared_future<std::int32_t> f =
165
            hpx::async(policy1, hpx::bind(&increment, 42));
×
166

167
        std::atomic<int> count(0);
×
168
        auto policy2 = hpx::launch::select([&count]() -> hpx::launch {
×
169
            if (count++ == 0)
×
170
                return hpx::launch::async;
×
171
            return hpx::launch::sync;
×
172
        });
×
173

174
        hpx::future<std::int32_t> f1 = hpx::async(policy2, inc, target, f);
×
175
        hpx::future<std::int32_t> f2 = hpx::async(policy2, inc, target, f);
×
176

177
        HPX_TEST_EQ(f1.get(), 44);
×
178
        HPX_TEST_EQ(f2.get(), 44);
×
179
    }
×
180
}
×
181

182
int hpx_main()
×
183
{
184
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
185
    for (hpx::id_type const& id : localities)
×
186
    {
187
        test_remote_async(id);
×
188
    }
189
    return hpx::finalize();
×
190
}
×
191

192
int main(int argc, char* argv[])
1✔
193
{
194
    // Initialize and run HPX
195
    HPX_TEST_EQ_MSG(
1✔
196
        hpx::init(argc, argv), 0, "HPX main exited with non-zero status");
197

198
    return hpx::util::report_errors();
1✔
199
}
×
200
#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

© 2025 Coveralls, Inc