• 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

75.0
/libs/core/execution_base/include/hpx/execution_base/agent_ref.hpp
1
//  Copyright (c) 2019 Thomas Heller
2
//  Copyright (c) 2023 Hartmut Kaiser
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/timing.hpp>
13

14
#include <chrono>
15
#include <cstddef>
16
#include <iosfwd>
17

18
namespace hpx::execution_base {
19

20
    HPX_CXX_EXPORT struct agent_base;
21

22
    HPX_CXX_EXPORT class HPX_CORE_EXPORT agent_ref
23
    {
24
    public:
25
        agent_ref() = default;
26
        ~agent_ref() = default;
27

28
        explicit constexpr agent_ref(agent_base* impl) noexcept
29
          : impl_(impl)
30
        {
31
        }
32

33
        agent_ref(agent_ref const&) = default;
34
        agent_ref& operator=(agent_ref const&) = default;
35
        agent_ref(agent_ref&&) = default;
36
        agent_ref& operator=(agent_ref&&) = default;
37

38
        explicit constexpr operator bool() const noexcept
39
        {
83,310✔
40
            return impl_ != nullptr;
41
        }
42

43
        void reset(agent_base* impl = nullptr) noexcept
44
        {
27,770✔
45
            impl_ = impl;
46
        }
47

48
        void yield(
49
            char const* desc = "hpx::execution_base::agent_ref::yield") const;
50
        bool yield_k(std::size_t k,
51
            char const* desc = "hpx::execution_base::agent_ref::yield_k") const;
52
        void suspend(
53
            char const* desc = "hpx::execution_base::agent_ref::suspend") const;
54
        void resume(hpx::threads::thread_priority priority =
55
                        hpx::threads::thread_priority::default_,
56
            char const* desc = "hpx::execution_base::agent_ref::resume") const;
57
        void abort(
58
            char const* desc = "hpx::execution_base::agent_ref::abort") const;
59

60
        template <typename Rep, typename Period>
61
        void sleep_for(std::chrono::duration<Rep, Period> const& sleep_duration,
62
            char const* desc = "hpx::execution_base::agent_ref::sleep_for")
63
        {
64
            sleep_for(hpx::chrono::steady_duration{sleep_duration}, desc);
65
        }
66

67
        template <typename Clock, typename Duration>
68
        void sleep_until(
69
            std::chrono::time_point<Clock, Duration> const& sleep_time,
70
            char const* desc = "hpx::execution_base::agent_ref::sleep_until")
×
71
        {
72
            sleep_until(hpx::chrono::steady_time_point{sleep_time}, desc);
73
        }
74

75
        [[nodiscard]] agent_base& ref() const noexcept
76
        {
77
            return *impl_;
78
        }
79

80
        // TODO:
81
        // affinity
82
        // thread_num
83
        // executor
84

85
    private:
86
        agent_base* impl_ = nullptr;
87

88
        void sleep_for(hpx::chrono::steady_duration const& sleep_duration,
89
            char const* desc) const;
90
        void sleep_until(hpx::chrono::steady_time_point const& sleep_time,
91
            char const* desc) const;
92

93
        friend constexpr bool operator==(
94
            agent_ref const& lhs, agent_ref const& rhs) noexcept
12,436✔
95
        {
96
            return lhs.impl_ == rhs.impl_;
97
        }
98

99
        friend constexpr bool operator!=(
100
            agent_ref const& lhs, agent_ref const& rhs) noexcept
101
        {
102
            return lhs.impl_ != rhs.impl_;
103
        }
104

105
        HPX_CORE_EXPORT friend std::ostream& operator<<(
106
            std::ostream&, agent_ref const&);
107
    };
108
}    // namespace hpx::execution_base
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