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

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

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

66.67
/libs/core/threading_base/src/get_default_pool.cpp
1
//  Copyright (c) 2007-2025 Hartmut Kaiser
2
//  Copyright (c)      2011 Bryce Lelbach
3
//  Copyright (c)      2020 Nikunj Gupta
4
//
5
//  SPDX-License-Identifier: BSL-1.0
6
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
7
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8

9
#include <hpx/assert.hpp>
10
#include <hpx/modules/errors.hpp>
11
#include <hpx/threading_base/detail/get_default_pool.hpp>
12
#include <hpx/threading_base/scheduler_base.hpp>
13
#include <hpx/threading_base/thread_description.hpp>
14
#include <hpx/threading_base/thread_pool_base.hpp>
15

16
// The following implementation has been divided for Linux and Mac OSX
17
#if defined(HPX_HAVE_DYNAMIC_HPX_MAIN) &&                                      \
18
    (defined(__linux) || defined(__linux__) || defined(linux) ||               \
19
        defined(__APPLE__))
20

21
namespace hpx_start {
22

23
    // Redefining weak variables defined in hpx_main.hpp to facilitate error
24
    // checking and make sure correct errors are thrown. It is added again to
25
    // make sure that these variables are defined correctly in cases where
26
    // hpx_main functionality is not used.
27
    HPX_SYMBOL_EXPORT bool is_linked __attribute__((weak)) = false;
28
    HPX_SYMBOL_EXPORT bool include_libhpx_wrap __attribute__((weak)) = false;
29
}    // namespace hpx_start
30

31
#endif
32

33
namespace hpx::threads::detail {
34

35
    static get_default_pool_type get_default_pool;
36

64✔
37
    void set_get_default_pool(get_default_pool_type f)
38
    {
39
        get_default_pool = HPX_MOVE(f);
64✔
40
    }
41

43,527✔
42
    thread_pool_base* get_self_or_default_pool()
43
    {
44
        thread_pool_base* pool = nullptr;
43,527✔
45
        if (auto const* thrd_data = get_self_id_data())
46
        {
47
            pool = thrd_data->get_scheduler_base()->get_parent_pool();
48
        }
308✔
49
        else if (detail::get_default_pool)
50
        {
51
            pool = detail::get_default_pool();
52
            HPX_ASSERT(pool);
53
        }
54
        else
55
        {
56
// The following implementation has been divided for Linux and Mac OSX
57
#if defined(HPX_HAVE_DYNAMIC_HPX_MAIN) &&                                      \
58
    (defined(__linux) || defined(__linux__) || defined(linux) ||               \
59
        defined(__APPLE__))
60

61
            // hpx_main.hpp is included but not linked to libhpx_wrap
×
62
            if (!hpx_start::is_linked && hpx_start::include_libhpx_wrap)
63
            {
×
64
                HPX_THROW_EXCEPTION(hpx::error::invalid_status,
65
                    "hpx::threads::detail::get_self_or_default_pool",
66
                    "Attempting to use hpx_main.hpp functionality "
67
                    "without linking to libhpx_wrap. If you're using "
68
                    "CMakeLists, make sure to add HPX::wrap_main to "
69
                    "target_link_libraries. "
70
                    "If you're using Makefile, make sure to link to "
71
                    "libhpx_wrap when generating the executable. If "
72
                    "you're linking explicitly, consult the HPX docs "
73
                    "for library link order and other subtle nuances.");
74
            }
75
#endif
×
76
            HPX_THROW_EXCEPTION(hpx::error::invalid_status,
77
                "hpx::threads::detail::get_self_or_default_pool",
78
                "Attempting to register a thread outside the HPX "
79
                "runtime and no default pool handler is installed. "
80
                "Did you mean to run this on an HPX thread?");
81
        }
43,527✔
82
        return pool;
83
    }
84
}    // namespace hpx::threads::detail
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