• 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

55.17
/libs/core/threading_base/src/thread_num_tss.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/modules/errors.hpp>
8
#include <hpx/threading_base/thread_num_tss.hpp>
9

10
#include <cstddef>
11
#include <tuple>
12
#include <utility>
13

14
namespace hpx::threads::detail {
15

16
    namespace {
17

18
        HPX_FORCEINLINE std::size_t& global_thread_num() noexcept
19
        {
20
            thread_local std::size_t global_thread_num_ =
21
                static_cast<std::size_t>(-1);
22
            return global_thread_num_;
23
        }
24

25
        HPX_FORCEINLINE std::size_t& local_thread_num() noexcept
26
        {
27
            thread_local std::size_t local_thread_num_ =
516✔
28
                static_cast<std::size_t>(-1);
29
            return local_thread_num_;
30
        }
516✔
31

32
        HPX_FORCEINLINE std::size_t& thread_pool_num() noexcept
33
        {
×
34
            thread_local std::size_t thread_pool_num_ =
35
                static_cast<std::size_t>(-1);
×
36
            return thread_pool_num_;
37
        }
38
    }    // namespace
130✔
39

40
    std::size_t set_global_thread_num_tss(std::size_t num) noexcept
41
    {
130✔
42
        std::swap(global_thread_num(), num);
43
        return num;
44
    }
83,157✔
45

46
    std::size_t get_global_thread_num_tss() noexcept
83,157✔
47
    {
48
        return global_thread_num();
49
    }
130✔
50

51
    std::size_t set_local_thread_num_tss(std::size_t num) noexcept
52
    {
130✔
53
        std::swap(local_thread_num(), num);
54
        return num;
55
    }
×
56

57
    std::size_t get_local_thread_num_tss() noexcept
×
58
    {
59
        return local_thread_num();
60
    }
×
61

62
    std::size_t set_thread_pool_num_tss(std::size_t num) noexcept
×
63
    {
×
64
        std::swap(thread_pool_num(), num);
65
        return num;
×
66
    }
67

×
68
    std::size_t get_thread_pool_num_tss() noexcept
69
    {
70
        return thread_pool_num();
71
    }
72

73
    void set_thread_nums_tss(thread_nums const& t) noexcept
326✔
74
    {
75
        global_thread_num() = t.global_thread_num;
326✔
76
        local_thread_num() = t.local_thread_num;
77
        thread_pool_num() = t.thread_pool_num;
78
    }
326✔
79

80
    thread_nums get_thread_nums_tss() noexcept
326✔
81
    {
82
        return {global_thread_num(), local_thread_num(), thread_pool_num()};
83
    }
714,234✔
84
}    // namespace hpx::threads::detail
85

714,234✔
86
namespace hpx {
87

88
    std::size_t get_worker_thread_num(error_code& /* ec */) noexcept
714,234✔
89
    {
90
        return threads::detail::global_thread_num();
714,234✔
91
    }
92

93
    std::size_t get_worker_thread_num() noexcept
×
94
    {
95
        return threads::detail::global_thread_num();
×
96
    }
97

98
    std::size_t get_local_worker_thread_num(error_code& /* ec */) noexcept
×
99
    {
100
        return threads::detail::local_thread_num();
×
101
    }
102

103
    std::size_t get_local_worker_thread_num() noexcept
104
    {
105
        return threads::detail::local_thread_num();
106
    }
107

108
    std::size_t get_thread_pool_num(error_code& /* ec */) noexcept
109
    {
110
        return threads::detail::thread_pool_num();
111
    }
112

113
    std::size_t get_thread_pool_num() noexcept
114
    {
115
        return threads::detail::thread_pool_num();
116
    }
117
}    // namespace hpx
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