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

STEllAR-GROUP / hpx / #854

18 Dec 2022 11:19PM UTC coverage: 86.511% (+0.2%) from 86.287%
#854

push

StellarBot
Merge #6111

6111: Modernize all modules from module level 8 r=hkaiser a=hkaiser

modules: datastructures, hashing, memory, checkpointing_base

- flyby: adding `hpx::construct_at`

working towards https://github.com/STEllAR-GROUP/hpx/issues/5497

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

127 of 127 new or added lines in 33 files covered. (100.0%)

174410 of 201605 relevant lines covered (86.51%)

1917096.95 hits per line

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

85.71
/libs/full/async_distributed/tests/unit/post_remote_client.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/actions.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 <cstdint>
19
#include <mutex>
20
#include <vector>
21

22
///////////////////////////////////////////////////////////////////////////////
23
bool root_locality = false;
24
std::int32_t final_result;
25
hpx::util::spinlock result_mutex;
1✔
26

27
void receive_result(std::int32_t i)
7✔
28
{
29
    std::lock_guard<hpx::util::spinlock> l(result_mutex);
7✔
30
    if (i > final_result)
7✔
31
        final_result = i;
7✔
32
}
7✔
33
HPX_PLAIN_ACTION(receive_result)
10✔
34

35
///////////////////////////////////////////////////////////////////////////////
36
std::atomic<std::int32_t> accumulator;
37

38
///////////////////////////////////////////////////////////////////////////////
39
struct increment_server
×
40
  : hpx::components::managed_component_base<increment_server>
41
{
42
    void call(hpx::id_type const& there, std::int32_t i) const
×
43
    {
44
        accumulator += i;
×
45
        hpx::post(receive_result_action(), there, accumulator.load());
×
46
    }
×
47

48
    HPX_DEFINE_COMPONENT_ACTION(increment_server, call)
49
};
50

51
typedef hpx::components::managed_component<increment_server> server_type;
52
HPX_REGISTER_COMPONENT(server_type, increment_server)
44✔
53

54
typedef increment_server::call_action call_action;
55
HPX_REGISTER_ACTION_DECLARATION(call_action)
56
HPX_REGISTER_ACTION(call_action)
18✔
57

58
///////////////////////////////////////////////////////////////////////////////
59
int hpx_main()
1✔
60
{
61
    hpx::id_type here = hpx::find_here();
1✔
62
    hpx::id_type there = here;
1✔
63
    root_locality = true;
1✔
64

65
    if (hpx::get_num_localities(hpx::launch::sync) > 1)
1✔
66
    {
67
        std::vector<hpx::id_type> localities = hpx::find_remote_localities();
1✔
68
        there = localities[0];
1✔
69
    }
1✔
70

71
    typedef hpx::components::client<increment_server> increment_client;
72

73
    {
74
        increment_client inc = hpx::components::new_<increment_client>(there);
1✔
75

76
        using hpx::placeholders::_1;
77
        using hpx::placeholders::_2;
78
        using hpx::placeholders::_3;
79

80
        call_action call;
81
        hpx::post(call, inc, here, 1);
1✔
82
        hpx::post(hpx::bind(call, inc, here, 1));
1✔
83
        hpx::post(hpx::bind(call, inc, here, _1), 1);
1✔
84
        hpx::post(hpx::bind(call, _1, here, 1), inc);
1✔
85
        hpx::post(hpx::bind(call, _1, _2, 1), inc, here);
1✔
86
        hpx::post(hpx::bind(call, _1, _2, _3), inc, here, 1);
1✔
87
    }
1✔
88

89
    {
90
        increment_client inc = hpx::components::new_<increment_client>(there);
1✔
91

92
        hpx::post<call_action>(inc, here, 1);
1✔
93
    }
1✔
94

95
    // Let finalize wait for every "apply" to be finished
96
    return hpx::finalize();
1✔
97
}
1✔
98

99
int main(int argc, char* argv[])
1✔
100
{
101
    accumulator.store(0);
1✔
102

103
    // Initialize and run HPX
104
    HPX_TEST_EQ_MSG(
1✔
105
        hpx::init(argc, argv), 0, "HPX main exited with non-zero status");
106

107
    // After hpx::init returns, all actions should have been executed
108
    // The final result is only accumulated on the root locality
109
    if (root_locality)
1✔
110
        HPX_TEST_EQ(final_result, 7);
1✔
111

112
    return hpx::util::report_errors();
1✔
113
}
×
114
#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