• 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

72.22
/libs/core/threading_base/src/create_thread.cpp
1
//  Copyright (c) 2007-2025 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
#include <hpx/modules/coroutines.hpp>
9
#include <hpx/modules/errors.hpp>
10
#include <hpx/modules/logging.hpp>
11
#include <hpx/threading_base/create_thread.hpp>
12
#include <hpx/threading_base/scheduler_base.hpp>
13
#include <hpx/threading_base/thread_data.hpp>
14
#include <hpx/threading_base/thread_init_data.hpp>
15

16
#include <cstddef>
17

18
namespace hpx::threads::detail {
907✔
19

20
    void create_thread(policies::scheduler_base* scheduler,
21
        threads::thread_init_data& data, threads::thread_id_ref_type& id,
22
        error_code& ec)
23
    {
907✔
24
        // verify parameters
25
        switch (data.initial_state)
26
        {
27
        // NOLINTNEXTLINE(bugprone-branch-clone)
28
        case thread_schedule_state::pending:
29
            [[fallthrough]];
30
        case thread_schedule_state::pending_do_not_schedule:
31
            [[fallthrough]];
32
        case thread_schedule_state::pending_boost:
33
            [[fallthrough]];
34
        case thread_schedule_state::suspended:
35
            break;
36

37
        default:
×
38
        {
39
            HPX_THROWS_IF(ec, hpx::error::bad_parameter,
40
                "threads::detail::create_thread", "invalid initial state: {}",
×
41
                data.initial_state);
42
            return;
43
        }
44
        }
45

46
#ifdef HPX_HAVE_THREAD_DESCRIPTION
47
        if (!data.description)
48
        {
49
            HPX_THROWS_IF(ec, hpx::error::bad_parameter,
50
                "threads::detail::create_thread", "description is nullptr");
51
            return;
52
        }
53
#endif
907✔
54

55
        thread_self const* self = get_self_ptr();
56

57
#ifdef HPX_HAVE_THREAD_PARENT_REFERENCE
58
        if (nullptr == data.parent_id)
59
        {
60
            if (self)
61
            {
62
                data.parent_id = get_thread_id_data(threads::get_self_id());
63
                data.parent_phase = self->get_thread_phase();
64
            }
65
        }
66
        if (0 == data.parent_locality_id)
67
            data.parent_locality_id = detail::get_locality_id(hpx::throws);
68
#endif
907✔
69

907✔
70
        if (nullptr == data.scheduler_base)
71
            data.scheduler_base = scheduler;
72

73
        // Pass critical priority from parent to child (but only if there is
907✔
74
        // none is explicitly specified).
75
        if (self)
1,055✔
76
        {
77
            if (data.priority == thread_priority::default_ &&
1,055✔
78
                thread_priority::high_recursive ==
79
                    get_thread_id_data(threads::get_self_id())->get_priority())
×
80
            {
81
                data.priority = thread_priority::high_recursive;
82
            }
83
        }
907✔
84

381✔
85
        if (data.priority == thread_priority::default_)
86
            data.priority = thread_priority::normal;
87

907✔
88
        // create the new thread
89
        scheduler->create_thread(data, &id, ec);
907✔
90

×
91
        LTM_(info)
92
            .format("create_thread: pool({}), scheduler({}), thread({}), "
93
                    "initial_state({}), run_now({})",
×
94
                *scheduler->get_parent_pool(), *scheduler, id,
95
                get_thread_state_name(data.initial_state), data.run_now)
96
#ifdef HPX_HAVE_THREAD_DESCRIPTION
97
            .format(", description({})", data.description)
98
#endif
99
            ;
100

101
        scheduler->do_some_work(data.schedulehint.mode ==
907✔
102
                    hpx::threads::thread_schedule_hint_mode::numa ?
103
                static_cast<std::size_t>(-1) :
104
                data.schedulehint.hint);
105
    }
106
}    // 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