• 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

68.75
/libs/core/threading_base/include/hpx/threading_base/thread_init_data.hpp
1
//  Copyright (c) 2007-2025 Hartmut Kaiser
2
//  Copyright (c) 2008-2009 Chirag Dekate, Anshul Tandon
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

8
#pragma once
9

10
#include <hpx/config.hpp>
11
#include <hpx/modules/coroutines.hpp>
12
#include <hpx/modules/errors.hpp>
13
#include <hpx/threading_base/thread_description.hpp>
14
#include <hpx/threading_base/threading_base_fwd.hpp>
15
#if defined(HPX_HAVE_APEX)
16
#include <hpx/threading_base/external_timer.hpp>
17
#endif
18

19
#include <cstddef>
20
#include <cstdint>
21
#include <utility>
22
#ifdef HPX_HAVE_APEX
23
#include <memory>
24
#endif
25

26
namespace hpx::threads {
27

28
    ///////////////////////////////////////////////////////////////////////////
89,071✔
29
    HPX_CXX_EXPORT class thread_init_data
30
    {
31
    public:
32
        thread_init_data()
86,276✔
33
          : func()
34
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
35
          , description()
36
#endif
37
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
38
          , parent_locality_id(0)
39
          , parent_id(nullptr)
40
          , parent_phase(0)
41
#endif
42
#ifdef HPX_HAVE_APEX
43
          , timer_data(nullptr)
44
#endif
86,276✔
45
          , schedulehint()
46
          , priority(thread_priority::normal)
86,276✔
47
          , stacksize(thread_stacksize::default_)
86,276✔
48
          , initial_state(thread_schedule_state::pending)
86,276✔
49
          , run_now(false)
86,276✔
50
          , scheduler_base(nullptr)
51
        {
52
            if (initial_state == thread_schedule_state::staged)
53
            {
54
                HPX_THROW_EXCEPTION(hpx::error::bad_parameter,
55
                    "thread_init_data::thread_init_data",
56
                    "threads shouldn't have 'staged' as their initial state");
57
            }
×
58
        }
59

60
        thread_init_data& operator=(thread_init_data const& rhs) = delete;
61
        thread_init_data& operator=(thread_init_data&& rhs) noexcept
62
        {
63
            func = HPX_MOVE(rhs.func);
×
64
            schedulehint = rhs.schedulehint;
×
65
            priority = rhs.priority;
×
66
            stacksize = rhs.stacksize;
×
67
            initial_state = rhs.initial_state;
×
68
            run_now = rhs.run_now;
×
69
            scheduler_base = rhs.scheduler_base;
70
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
71
            description = HPX_MOVE(rhs.description);
72
#endif
73
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
74
            parent_locality_id = rhs.parent_locality_id;
75
            parent_id = HPX_MOVE(rhs.parent_id);
76
            parent_phase = rhs.parent_phase;
77
#endif
78
#ifdef HPX_HAVE_APEX
79
            // HPX_HAVE_APEX forces the HPX_HAVE_THREAD_DESCRIPTION
80
            // and HPX_HAVE_THREAD_PARENT_REFERENCE settings to be on
81
            timer_data = rhs.timer_data;
82
#endif
83
            return *this;
84
        }
85

86
        thread_init_data(thread_init_data const& rhs) = delete;
87
        thread_init_data(thread_init_data&& rhs) noexcept
42,923✔
88
          : func(HPX_MOVE(rhs.func))
89
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
90
          , description(HPX_MOVE(rhs.description))
91
#endif
92
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
93
          , parent_locality_id(rhs.parent_locality_id)
94
          , parent_id(HPX_MOVE(rhs.parent_id))
95
          , parent_phase(rhs.parent_phase)
96
#endif
97
#ifdef HPX_HAVE_APEX
98
          // HPX_HAVE_APEX forces the HPX_HAVE_THREAD_DESCRIPTION and
99
          // HPX_HAVE_THREAD_PARENT_REFERENCE settings to be on
100
          , timer_data(util::external_timer::new_task(
101
                description, parent_locality_id, parent_id))
102
#endif
42,923✔
103
          , schedulehint(rhs.schedulehint)
42,923✔
104
          , priority(rhs.priority)
42,923✔
105
          , stacksize(rhs.stacksize)
42,923✔
106
          , initial_state(rhs.initial_state)
42,923✔
107
          , run_now(rhs.run_now)
42,923✔
108
          , scheduler_base(rhs.scheduler_base)
109
        {
110
        }
111

112
        template <typename F>
2,795✔
113
        thread_init_data(F&& f,
114
            [[maybe_unused]] threads::thread_description const& desc,
115
            thread_priority priority_ = thread_priority::normal,
116
            thread_schedule_hint os_thread = thread_schedule_hint(),
117
            thread_stacksize stacksize_ = thread_stacksize::default_,
118
            thread_schedule_state initial_state_ =
119
                thread_schedule_state::pending,
120
            bool run_now_ = false,
121
            policies::scheduler_base* scheduler_base_ = nullptr)
300✔
122
          : func(HPX_FORWARD(F, f))
123
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
124
          , description(desc)
125
#endif
126
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
127
          , parent_locality_id(0)
128
          , parent_id(nullptr)
129
          , parent_phase(0)
130
#endif
131
#ifdef HPX_HAVE_APEX
132
          // HPX_HAVE_APEX forces the HPX_HAVE_THREAD_DESCRIPTION and
133
          // HPX_HAVE_THREAD_PARENT_REFERENCE settings to be on
134
          , timer_data(util::external_timer::new_task(
135
                description, parent_locality_id, parent_id))
136
#endif
2,795✔
137
          , schedulehint(os_thread)
2,795✔
138
          , priority(priority_)
2,795✔
139
          , stacksize(stacksize_)
2,795✔
140
          , initial_state(initial_state_)
2,795✔
141
          , run_now(run_now_)
2,795✔
142
          , scheduler_base(scheduler_base_)
143
        {
×
144
            if (initial_state == thread_schedule_state::staged)
145
            {
×
146
                HPX_THROW_EXCEPTION(hpx::error::bad_parameter,
147
                    "thread_init_data::thread_init_data",
148
                    "threads shouldn't have 'staged' as their initial state");
149
            }
×
150
        }
151

152
        threads::thread_function_type func;
153

154
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
155
        threads::thread_description description;
156
#endif
157
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
158
        std::uint32_t parent_locality_id;
159
        threads::thread_id_type parent_id;
160
        std::size_t parent_phase;
161
#endif
162
#ifdef HPX_HAVE_APEX
163
        // HPX_HAVE_APEX forces the HPX_HAVE_THREAD_DESCRIPTION and
164
        // HPX_HAVE_THREAD_PARENT_REFERENCE settings to be on
165
        std::shared_ptr<util::external_timer::task_wrapper> timer_data;
166
#endif
167

168
        thread_schedule_hint schedulehint;
169
        thread_priority priority;
170
        thread_stacksize stacksize;
171
        thread_schedule_state initial_state;
172
        bool run_now;
173

174
        policies::scheduler_base* scheduler_base;
175
    };
176
}    // namespace hpx::threads
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