• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #853

19 Dec 2022 01:01AM UTC coverage: 86.287% (+0.4%) from 85.912%
#853

push

StellarBot
Merge #6109

6109: Modernize serialization module r=hkaiser a=hkaiser

- flyby separate serialization of Boost types

working towards https://github.com/STEllAR-GROUP/hpx/issues/5497

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

53 of 53 new or added lines in 6 files covered. (100.0%)

173939 of 201582 relevant lines covered (86.29%)

1931657.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

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

9
#pragma once
10

11
#include <hpx/config.hpp>
12
#include <hpx/allocator_support/internal_allocator.hpp>
13
#include <hpx/assert.hpp>
14
#include <hpx/coroutines/stackless_coroutine.hpp>
15
#include <hpx/coroutines/thread_enums.hpp>
16
#include <hpx/functional/function.hpp>
17
#include <hpx/modules/errors.hpp>
18
#include <hpx/threading_base/thread_data.hpp>
19
#include <hpx/threading_base/thread_init_data.hpp>
20

21
#include <cstddef>
22
#include <memory>
23
#include <utility>
24

25
#include <hpx/config/warnings_prefix.hpp>
26

27
///////////////////////////////////////////////////////////////////////////////
28
namespace hpx { namespace threads {
29

30
    ///////////////////////////////////////////////////////////////////////////
31
    /// A \a thread is the representation of a ParalleX thread. It's a first
32
    /// class object in ParalleX. In our implementation this is a user level
33
    /// thread running on top of one of the OS threads spawned by the \a
34
    /// thread-manager.
35
    ///
36
    /// A \a thread encapsulates:
37
    ///  - A thread status word (see the functions \a thread#get_state and
38
    ///    \a thread#set_state)
39
    ///  - A function to execute (the thread function)
40
    ///  - A frame (in this implementation this is a block of memory used as
41
    ///    the threads stack)
42
    ///  - A block of registers (not implemented yet)
43
    ///
44
    /// Generally, \a threads are not created or executed directly. All
45
    /// functionality related to the management of \a threads is
46
    /// implemented by the thread-manager.
47
    class HPX_CORE_EXPORT thread_data_stackless : public thread_data
48
    {
49
    private:
50
        // Avoid warning about using 'this' in initializer list
51
        thread_data* this_()
1✔
52
        {
53
            return this;
1✔
54
        }
55

56
        static util::internal_allocator<thread_data_stackless> thread_alloc_;
57

58
    public:
59
        stackless_coroutine_type::result_type call()
1✔
60
        {
61
            HPX_ASSERT(get_state().state() == thread_schedule_state::active);
1✔
62
            HPX_ASSERT(this == coroutine_.get_thread_id().get());
1✔
63

64
            return coroutine_(this->thread_data::set_state_ex(
1✔
65
                thread_restart_state::signaled));
66
        }
67

68
#if defined(HPX_DEBUG)
69
        thread_id_type get_thread_id() const override
×
70
        {
71
            HPX_ASSERT(this == coroutine_.get_thread_id().get());
×
72
            return this->thread_data::get_thread_id();
×
73
        }
74
#endif
75
#if defined(HPX_HAVE_THREAD_PHASE_INFORMATION)
76
        std::size_t get_thread_phase() const noexcept override
77
        {
78
            return coroutine_.get_thread_phase();
79
        }
80
#endif
81

82
        std::size_t get_thread_data() const override
×
83
        {
84
            return coroutine_.get_thread_data();
×
85
        }
86

87
        std::size_t set_thread_data(std::size_t data) override
×
88
        {
89
            return coroutine_.set_thread_data(data);
×
90
        }
91

92
#if defined(HPX_HAVE_LIBCDS)
93
        std::size_t get_libcds_data() const override
94
        {
95
            return coroutine_.get_libcds_data();
96
        }
97

98
        std::size_t set_libcds_data(std::size_t data) override
99
        {
100
            return coroutine_.set_libcds_data(data);
101
        }
102

103
        std::size_t get_libcds_hazard_pointer_data() const override
104
        {
105
            return coroutine_.get_libcds_hazard_pointer_data();
106
        }
107

108
        std::size_t set_libcds_hazard_pointer_data(std::size_t data) override
109
        {
110
            return coroutine_.set_libcds_hazard_pointer_data(data);
111
        }
112

113
        std::size_t get_libcds_dynamic_hazard_pointer_data() const override
114
        {
115
            return coroutine_.get_libcds_dynamic_hazard_pointer_data();
116
        }
117

118
        std::size_t set_libcds_dynamic_hazard_pointer_data(
119
            std::size_t data) override
120
        {
121
            return coroutine_.set_libcds_dynamic_hazard_pointer_data(data);
122
        }
123
#endif
124

125
        void init() override {}
×
126

127
        void rebind(thread_init_data& init_data) override
×
128
        {
129
            this->thread_data::rebind_base(init_data);
×
130

131
            coroutine_.rebind(HPX_MOVE(init_data.func), thread_id_type(this));
×
132

133
            HPX_ASSERT(coroutine_.is_ready());
×
134
        }
×
135

136
        thread_data_stackless(thread_init_data& init_data, void* queue,
1✔
137
            std::ptrdiff_t stacksize, thread_id_addref addref)
138
          : thread_data(init_data, queue, stacksize, true, addref)
1✔
139
          , coroutine_(HPX_MOVE(init_data.func), thread_id_type(this_()))
1✔
140
        {
2✔
141
            HPX_ASSERT(coroutine_.is_ready());
1✔
142
        }
1✔
143

144
        ~thread_data_stackless();
145

146
        inline static thread_data* create(thread_init_data& data, void* queue,
147
            std::ptrdiff_t stacksize,
148
            thread_id_addref addref = thread_id_addref::yes);
149

150
        void destroy() noexcept override
1✔
151
        {
152
            std::destroy_at(this);
1✔
153
            thread_alloc_.deallocate(this, 1);
1✔
154
        }
1✔
155

156
    private:
157
        stackless_coroutine_type coroutine_;
158
    };
159

160
    ////////////////////////////////////////////////////////////////////////////
161
    inline thread_data* thread_data_stackless::create(thread_init_data& data,
1✔
162
        void* queue, std::ptrdiff_t stacksize, thread_id_addref addref)
163
    {
164
        thread_data* p = thread_alloc_.allocate(1);
1✔
165
        new (p) thread_data_stackless(data, queue, stacksize, addref);
1✔
166
        return p;
1✔
167
    }
168
}}    // namespace hpx::threads
169

170
#include <hpx/config/warnings_suffix.hpp>
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