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

STEllAR-GROUP / hpx / #857

28 Dec 2022 11:12PM UTC coverage: 86.543% (-0.06%) from 86.602%
#857

push

StellarBot
Merge #6118

6118: Modernize modules from level 17, 18, 19, and 20 r=hkaiser a=hkaiser

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

Modules:
- core/threading_base
- full/command_line_handling
- core/io_service
- core/schedulers
- core/synchronization
- core/futures
- core/thread_pools
- core/lcos_local
- core/pack_traversal
- core/resource_partitioner
- core/threading
- full/naming_base


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

849 of 849 new or added lines in 98 files covered. (100.0%)

174389 of 201505 relevant lines covered (86.54%)

1916353.25 hits per line

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

32.69
/libs/full/async_colocated/tests/unit/post_colocated.cpp
1
//  Copyright (c) 2007-2014 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 on_shutdown_executed = false;
24
std::uint32_t locality_id = std::uint32_t(-1);
25

26
std::int32_t final_result = 0;
27
hpx::util::spinlock result_mutex;
1✔
28

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

37
///////////////////////////////////////////////////////////////////////////////
38
std::atomic<std::int32_t> accumulator;
39

40
void increment(hpx::id_type const& there, std::int32_t i)
3✔
41
{
42
    locality_id = hpx::get_locality_id();
3✔
43

44
    accumulator += i;
3✔
45
    hpx::post(receive_result_action(), there, accumulator.load());
3✔
46
}
3✔
47
HPX_PLAIN_ACTION(increment)
6✔
48

49
///////////////////////////////////////////////////////////////////////////////
50
struct increment_server
4✔
51
  : hpx::components::managed_component_base<increment_server>
52
{
53
    void call(hpx::id_type const& there, std::int32_t i) const
×
54
    {
55
        accumulator += i;
×
56
        hpx::post(receive_result_action(), there, accumulator.load());
×
57
    }
×
58

59
    HPX_DEFINE_COMPONENT_ACTION(increment_server, call)
60
};
61

62
typedef hpx::components::managed_component<increment_server> server_type;
63
HPX_REGISTER_COMPONENT(server_type, increment_server)
41✔
64

65
typedef increment_server::call_action call_action;
66
HPX_REGISTER_ACTION_DECLARATION(call_action)
67
HPX_REGISTER_ACTION(call_action)
3✔
68

69
///////////////////////////////////////////////////////////////////////////////
70
void on_shutdown()
×
71
{
72
    std::lock_guard<hpx::util::spinlock> l(result_mutex);
×
73
    HPX_TEST_EQ(final_result, 3);
×
74

75
    on_shutdown_executed = true;
×
76
}
×
77

78
///////////////////////////////////////////////////////////////////////////////
79
int hpx_main()
×
80
{
81
    locality_id = hpx::get_locality_id();
×
82

83
    hpx::id_type here = hpx::find_here();
×
84
    hpx::id_type there = here;
×
85
    if (hpx::get_num_localities(hpx::launch::sync) > 1)
×
86
    {
87
        std::vector<hpx::id_type> localities = hpx::find_remote_localities();
×
88
        there = localities[0];
×
89
    }
×
90

91
    {
92
        increment_action inc;
93
        hpx::post(inc, hpx::colocated(there), here, 1);
×
94
    }
95

96
    {
97
        hpx::future<hpx::id_type> inc_f =
98
            hpx::components::new_<increment_server>(there);
×
99
        hpx::id_type where = inc_f.get();
×
100

101
        increment_action inc;
102
        hpx::post(inc, hpx::colocated(where), here, 1);
×
103
    }
×
104

105
    {
106
        hpx::future<hpx::id_type> inc_f =
107
            hpx::components::new_<increment_server>(there);
×
108
        hpx::id_type where = inc_f.get();
×
109

110
        hpx::post<increment_action>(hpx::colocated(where), here, 1);
×
111
    }
×
112

113
    // register function which will verify final result
114
    hpx::register_shutdown_function(on_shutdown);
×
115

116
    HPX_TEST_EQ(hpx::finalize(), 0);
×
117

118
    return 0;
119
}
×
120

121
int main(int argc, char* argv[])
1✔
122
{
123
    accumulator.store(0);
1✔
124

125
    // Initialize and run HPX
126
    HPX_TEST_EQ_MSG(
1✔
127
        hpx::init(argc, argv), 0, "HPX main exited with non-zero status");
128

129
    HPX_TEST_NEQ(std::uint32_t(-1), locality_id);
1✔
130
    HPX_TEST_NEQ(on_shutdown_executed || 0, locality_id);
1✔
131

132
    return hpx::util::report_errors();
1✔
133
}
×
134
#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