• 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

58.97
/libs/full/actions/src/base_action.cpp
1
//  Copyright (c) 2018-2024 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

9
#if defined(HPX_HAVE_NETWORKING)
10
#include <hpx/actions/transfer_action.hpp>
11
#include <hpx/modules/datastructures.hpp>
12
#include <hpx/modules/runtime_local.hpp>
13
#include <hpx/modules/serialization.hpp>
14

15
#include <cstdint>
16

17
#include <hpx/config/warnings_prefix.hpp>
18

19
///////////////////////////////////////////////////////////////////////////////
20
namespace hpx::actions::detail {
21

22
    ///////////////////////////////////////////////////////////////////////////
23
    struct action_serialization_data
24
    {
25
        action_serialization_data()
26
          : parent_id_(static_cast<std::uint64_t>(0))
27
          , parent_phase_(0)
414✔
28
          , parent_locality_(naming::invalid_locality_id)
414✔
29
          , priority_(static_cast<threads::thread_priority>(0))
414✔
30
          , stacksize_(static_cast<threads::thread_stacksize>(0))
414✔
31
        {
414✔
32
        }
33

34
        action_serialization_data(std::uint32_t parent_locality,
35
            threads::thread_id_type parent_id, std::uint64_t parent_phase,
36
            threads::thread_priority priority,
37
            threads::thread_stacksize stacksize)
38
          : parent_id_(reinterpret_cast<std::uint64_t>(parent_id.get()))
39
          , parent_phase_(parent_phase)
837✔
40
          , parent_locality_(parent_locality)
837✔
41
          , priority_(priority)
837✔
42
          , stacksize_(stacksize)
837✔
43
        {
837✔
44
        }
45

46
        std::uint64_t parent_id_;
47
        std::uint64_t parent_phase_;
48
        std::uint32_t parent_locality_;
49
        threads::thread_priority priority_;
50
        threads::thread_stacksize stacksize_;
51

52
        template <typename Archive>
53
        void serialize(Archive& ar, unsigned)
54
        {
×
55
            // clang-format off
56
            ar & parent_id_ & parent_phase_ & parent_locality_ & priority_ &
57
                stacksize_;
×
58
            // clang-format on
×
59
        }
60
    };
×
61
}    // namespace hpx::actions::detail
62

63
HPX_IS_BITWISE_SERIALIZABLE(hpx::actions::detail::action_serialization_data)
64

65
///////////////////////////////////////////////////////////////////////////////
66
namespace hpx::actions {
67

68
    ///////////////////////////////////////////////////////////////////////////
69
    base_action::~base_action() {}
70

828✔
71
    ///////////////////////////////////////////////////////////////////////////
72
    base_action_data::base_action_data(
73
        threads::thread_priority priority, threads::thread_stacksize stacksize)
414✔
74
      : priority_(priority)
414✔
75
      , stacksize_(stacksize)
414✔
76
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
414✔
77
      , parent_locality_(base_action_data::get_locality_id())
78
      , parent_id_(threads::get_parent_id())
79
      , parent_phase_(threads::get_parent_phase())
80
#endif
81
    {
82
    }
83

414✔
84
    // serialization support
85
    // loading ...
86
    void base_action_data::load_base(hpx::serialization::input_archive& ar)
87
    {
414✔
88
        // Always serialize the parent information to maintain binary
89
        // compatibility on the wire.
90

91
        detail::action_serialization_data data;
92
        ar >> data;
93

94
#if defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
95
        parent_locality_ = data.parent_locality_;
96
        parent_id_ =
97
            threads::thread_id_type(reinterpret_cast<void*>(data.parent_id_));
98
        parent_phase_ = data.parent_phase_;
99
#endif
100
        priority_ = data.priority_;
101
        stacksize_ = data.stacksize_;
414✔
102
    }
414✔
103

414✔
104
    // saving ...
105
    void base_action_data::save_base(
106
        hpx::serialization::output_archive& ar) const
837✔
107
    {
108
        // Always serialize the parent information to maintain binary
109
        // compatibility on the wire.
110

111
#if !defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
112
        constexpr std::uint32_t parent_locality_ = naming::invalid_locality_id;
113
        threads::thread_id_type const parent_id_;
114
        constexpr std::uint64_t parent_phase_ = 0;
115
#endif
116
        detail::action_serialization_data const data(
117
            parent_locality_, parent_id_, parent_phase_, priority_, stacksize_);
837✔
118
        ar << data;
119
    }
837✔
120

121
    ///////////////////////////////////////////////////////////////////////////
122
    std::uint32_t base_action_data::get_locality_id()
×
123
    {
124
        hpx::error_code ec(hpx::throwmode::lightweight);    // ignore any errors
125
        return hpx::get_locality_id(ec);
×
126
    }
127

128
///////////////////////////////////////////////////////////////////////////
129
#if !defined(HPX_HAVE_THREAD_PARENT_REFERENCE)
130
    /// Return the locality of the parent thread
131
    std::uint32_t base_action_data::get_parent_locality_id() const
×
132
    {
133
        return naming::invalid_locality_id;
×
134
    }
135

136
    /// Return the thread id of the parent thread
137
    threads::thread_id_type base_action_data::get_parent_thread_id() const
×
138
    {
139
        return threads::invalid_thread_id;
×
140
    }
141

142
    /// Return the phase of the parent thread
143
    std::uint64_t base_action_data::get_parent_thread_phase() const
×
144
    {
145
        return 0;
×
146
    }
147
#else
148
    /// Return the locality of the parent thread
149
    std::uint32_t base_action_data::get_parent_locality_id() const
150
    {
151
        return parent_locality_;
152
    }
153

154
    /// Return the thread id of the parent thread
155
    threads::thread_id_type base_action_data::get_parent_thread_id() const
156
    {
157
        return parent_id_;
158
    }
159

160
    /// Return the phase of the parent thread
161
    std::uint64_t base_action_data::get_parent_thread_phase() const
162
    {
163
        return parent_phase_;
164
    }
165
#endif
166

167
    /// Return the thread priority this action has to be executed with
168
    threads::thread_priority base_action_data::get_thread_priority() const
×
169
    {
170
        return priority_;
×
171
    }
172

173
    /// Return the thread stacksize this action has to be executed with
174
    threads::thread_stacksize base_action_data::get_thread_stacksize() const
×
175
    {
176
        return stacksize_;
×
177
    }
178
}    // namespace hpx::actions
179

180
#endif
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

© 2026 Coveralls, Inc