• 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

34.29
/libs/core/threading_base/src/thread_description.cpp
1
//  Copyright (c) 2016-2022 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/assert.hpp>
9
#include <hpx/modules/format.hpp>
10
#include <hpx/threading_base/thread_data.hpp>
11
#include <hpx/threading_base/thread_description.hpp>
12
#include <hpx/type_support/unused.hpp>
13
#include <hpx/util/to_string.hpp>
14

15
#include <ostream>
16
#include <string>
17

18
namespace hpx::threads {
19

20
    std::ostream& operator<<(
39,549,761✔
21
        std::ostream& os, [[maybe_unused]] thread_description const& d)
22
    {
23
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
24
        if (d.kind() == thread_description::data_type_description)
25
        {
26
            os << d.get_description();
27
        }
28
        else
29
        {
30
            HPX_ASSERT(d.kind() == thread_description::data_type_address);
31
            os << d.get_address();    //-V128
32
        }
33
#else
34
        os << "<unknown>";
39,550,297✔
35
#endif
36
        return os;
39,550,297✔
37
    }
38

39
    std::string as_string([[maybe_unused]] thread_description const& desc)
2,535✔
40
    {
41
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
42
        if (desc.kind() == threads::thread_description::data_type_description)
43
            return desc ? desc.get_description() : "<unknown>";
44

45
        return hpx::util::format("address: {:#x}", desc.get_address());
46
#else
47
        return "<unknown>";
2,535✔
48
#endif
49
    }
×
50

51
    /* The priority of description is altname, id::name, id::address */
52
    void thread_description::init_from_alternative_name(
×
53
        [[maybe_unused]] char const* altname)
54
    {
55
#if defined(HPX_HAVE_THREAD_DESCRIPTION) &&                                    \
56
    !defined(HPX_HAVE_THREAD_DESCRIPTION_FULL)
57
        if (altname != nullptr)
58
        {
59
            type_ = data_type_description;
60
            data_.desc_ = altname;
61
            return;
62
        }
63

64
        hpx::threads::thread_id_type id = hpx::threads::get_self_id();
65
        if (id)
66
        {
67
            // get the current task description
68
            thread_description desc = hpx::threads::get_thread_description(id);
69
            type_ = desc.kind();
70
            // if the current task has a description, use it.
71
            if (type_ == data_type_description)
72
            {
73
                data_.desc_ = desc.get_description();
74
            }
75
            else
76
            {
77
                // otherwise, use the address of the task.
78
                HPX_ASSERT(type_ == data_type_address);
79
                data_.addr_ = desc.get_address();
80
            }
81
        }
82
        else
83
        {
84
            type_ = data_type_description;
85
            data_.desc_ = "<unknown>";
86
        }
87
#endif
88
    }
×
89

90
    threads::thread_description get_thread_description(
9,442✔
91
        thread_id_type const& id, error_code& /* ec */)
92
    {
93
        return id ? get_thread_id_data(id)->get_description() :
9,442✔
94
                    threads::thread_description("<unknown>");
×
95
    }
96

97
    threads::thread_description set_thread_description(thread_id_type const& id,
1,685✔
98
        threads::thread_description const& desc, error_code& ec)
99
    {
100
        if (HPX_UNLIKELY(!id))
1,685✔
101
        {
102
            HPX_THROWS_IF(ec, hpx::error::null_thread_id,
×
103
                "hpx::threads::set_thread_description",
104
                "null thread id encountered");
105
            return threads::thread_description();
×
106
        }
107
        if (&ec != &throws)
1,685✔
108
            ec = make_success_code();
×
109

110
        return get_thread_id_data(id)->set_description(desc);
1,685✔
111
    }
1,685✔
112

113
    ///////////////////////////////////////////////////////////////////////////
114
    threads::thread_description get_thread_lco_description(
×
115
        thread_id_type const& id, error_code& ec)
116
    {
117
        if (HPX_UNLIKELY(!id))
×
118
        {
119
            HPX_THROWS_IF(ec, hpx::error::null_thread_id,
×
120
                "hpx::threads::get_thread_lco_description",
121
                "null thread id encountered");
122
            return nullptr;
×
123
        }
124

125
        if (&ec != &throws)
×
126
            ec = make_success_code();
×
127

128
        return get_thread_id_data(id)->get_lco_description();
×
129
    }
×
130

131
    threads::thread_description set_thread_lco_description(
×
132
        thread_id_type const& id, threads::thread_description const& desc,
133
        error_code& ec)
134
    {
135
        if (HPX_UNLIKELY(!id))
×
136
        {
137
            HPX_THROWS_IF(ec, hpx::error::null_thread_id,
×
138
                "hpx::threads::set_thread_lco_description",
139
                "null thread id encountered");
140
            return nullptr;
×
141
        }
142

143
        if (&ec != &throws)
×
144
            ec = make_success_code();
×
145

146
        return get_thread_id_data(id)->set_lco_description(desc);
×
147
    }
×
148
}    // 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