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

STEllAR-GROUP / hpx / #862

10 Jan 2023 05:30PM UTC coverage: 86.582% (-0.05%) from 86.634%
#862

push

StellarBot
Merge #6130

6130: Remove the mutex lock in the critical path of get_partitioner. r=hkaiser a=JiakunYan

Remove the mutex lock in the critical path of hpx::resource::detail::get_partitioner.

The protected variable `partitioner_ref` is only set once during initialization.

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

6 of 6 new or added lines in 1 file covered. (100.0%)

174767 of 201851 relevant lines covered (86.58%)

2069816.07 hits per line

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

87.3
/libs/core/runtime_configuration/src/static_factory_data.cpp
1
//  Copyright (c) 2005-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/runtime_configuration/static_factory_data.hpp>
8

9
#include <map>
10
#include <string>
11
#include <utility>
12
#include <vector>
13

14
namespace hpx::components {
15

16
    bool& get_initial_static_loading() noexcept
33,144✔
17
    {
18
        static bool initial_static_loading = true;
19
        return initial_static_loading;
33,144✔
20
    }
21

22
    ///////////////////////////////////////////////////////////////////////////
23
    // There is no need to protect these global from thread concurrent access
24
    // as they are access during early startup only.
25
    std::vector<static_factory_load_data_type>& get_static_module_data()
2,012✔
26
    {
27
        static std::vector<static_factory_load_data_type>
2,012✔
28
            global_module_init_data;
1,162✔
29
        return global_module_init_data;
2,012✔
30
    }
31

32
    void init_registry_module(
1,418✔
33
        static_factory_load_data_type const& data)    //-V835
34
    {
35
        if (get_initial_static_loading())
1,418✔
36
        {
37
            get_static_module_data().push_back(data);
1,418✔
38
        }
1,418✔
39
    }
1,418✔
40

41
    ///////////////////////////////////////////////////////////////////////////
42
    std::map<std::string, util::plugin::get_plugins_list_type>&
43
    get_static_factory_data()
47,276✔
44
    {
45
        static std::map<std::string, util::plugin::get_plugins_list_type>
47,276✔
46
            global_factory_init_data;
1,162✔
47
        return global_factory_init_data;
47,276✔
48
    }
49

50
    void init_registry_factory(
31,039✔
51
        static_factory_load_data_type const& data)    //-V835
52
    {
53
        if (get_initial_static_loading())
31,039✔
54
        {
55
            get_static_factory_data().emplace(data.name, data.get_factory);
31,039✔
56
        }
31,039✔
57
    }
31,039✔
58

59
    bool get_static_factory(
16,237✔
60
        std::string const& instance, util::plugin::get_plugins_list_type& f)
61
    {
62
        using map_type =
63
            std::map<std::string, util::plugin::get_plugins_list_type>;
64

65
        map_type const& m = get_static_factory_data();
16,237✔
66
        map_type::const_iterator it = m.find(instance);
16,237✔
67
        if (it == m.end())
16,237✔
68
            return false;
×
69

70
        f = it->second;
16,237✔
71
        return true;
16,237✔
72
    }
16,237✔
73

74
    ///////////////////////////////////////////////////////////////////////////
75
    std::map<std::string, util::plugin::get_plugins_list_type>&
76
    get_static_commandline_data()
846✔
77
    {
78
        static std::map<std::string, util::plugin::get_plugins_list_type>
846✔
79
            global_commandline_init_data;
489✔
80
        return global_commandline_init_data;
846✔
81
    }
82

83
    void init_registry_commandline(
×
84
        static_factory_load_data_type const& data)    //-V835
85
    {
86
        if (get_initial_static_loading())
×
87
        {
88
            get_static_commandline_data().emplace(data.name, data.get_factory);
×
89
        }
×
90
    }
×
91

92
    bool get_static_commandline(
846✔
93
        std::string const& instance, util::plugin::get_plugins_list_type& f)
94
    {
95
        using map_type =
96
            std::map<std::string, util::plugin::get_plugins_list_type>;
97

98
        map_type const& m = get_static_commandline_data();
846✔
99
        map_type::const_iterator it = m.find(instance);
846✔
100
        if (it == m.end())
846✔
101
            return false;
846✔
102

103
        f = it->second;
×
104
        return true;
×
105
    }
846✔
106

107
    ///////////////////////////////////////////////////////////////////////////
108
    std::map<std::string, util::plugin::get_plugins_list_type>&
109
    get_static_startup_shutdown_data()
939✔
110
    {
111
        static std::map<std::string, util::plugin::get_plugins_list_type>
939✔
112
            global_startup_shutdown_init_data;
491✔
113
        return global_startup_shutdown_init_data;
939✔
114
    }
115

116
    void init_registry_startup_shutdown(
93✔
117
        static_factory_load_data_type const& data)    //-V835
118
    {
119
        if (get_initial_static_loading())
93✔
120
        {
121
            get_static_startup_shutdown_data().emplace(
186✔
122
                data.name, data.get_factory);
93✔
123
        }
93✔
124
    }
93✔
125

126
    bool get_static_startup_shutdown(
846✔
127
        std::string const& instance, util::plugin::get_plugins_list_type& f)
128
    {
129
        using map_type =
130
            std::map<std::string, util::plugin::get_plugins_list_type>;
131

132
        map_type const& m = get_static_startup_shutdown_data();
846✔
133
        map_type::const_iterator it = m.find(instance);
846✔
134
        if (it == m.end())
846✔
135
            return false;
755✔
136

137
        f = it->second;
91✔
138
        return true;
91✔
139
    }
846✔
140
}    // namespace hpx::components
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