• 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

0.0
/libs/full/runtime_distributed/include/hpx/runtime_distributed/copy_component.hpp
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
/// \file copy_component.hpp
8

9
#pragma once
10

11
#include <hpx/config.hpp>
12
#include <hpx/actions_base/plain_action.hpp>
13
#include <hpx/async_colocated/async_colocated.hpp>
14
#include <hpx/async_distributed/async.hpp>
15
#include <hpx/components_base/traits/is_component.hpp>
16
#include <hpx/modules/futures.hpp>
17
#include <hpx/naming_base/id_type.hpp>
18
#include <hpx/runtime_distributed/server/copy_component.hpp>
19

20
#include <type_traits>
21

22
namespace hpx::components {
23

24
    /// \brief Copy given component to the specified target locality
25
    ///
26
    /// The function \a copy<Component> will create a copy of the component
27
    /// referenced by \a to_copy on the locality specified with
28
    /// \a target_locality. It returns a future referring to the newly created
29
    /// component instance.
30
    ///
31
    /// \param to_copy         [in] The global id of the component to copy
32
    ///
33
    /// \tparam  The only template argument specifies the component type to
34
    ///          create.
35
    ///
36
    /// \returns A future representing the global id of the newly (copied)
37
    ///          component instance.
38
    ///
39
    /// \note The new component instance is created on the locality of the
40
    ///       component instance which is to be copied.
41
    ///
42
    template <typename Component>
43
#if defined(DOXYGEN)
44
    future<hpx::id_type>
45
#else
46
    std::enable_if_t<traits::is_component_v<Component>, future<hpx::id_type>>
47
#endif
48
    copy(hpx::id_type const& to_copy)
49
    {
×
50
        using action_type = server::copy_component_action_here<Component>;
51
        return hpx::detail::async_colocated<action_type>(to_copy, to_copy);
52
    }
×
53

54
    /// \brief Copy given component to the specified target locality
55
    ///
56
    /// The function \a copy<Component> will create a copy of the component
57
    /// referenced by \a to_copy on the locality specified with
58
    /// \a target_locality. It returns a future referring to the newly created
59
    /// component instance.
60
    ///
61
    /// \param to_copy         [in] The global id of the component to copy
62
    /// \param target_locality [in ] The locality where the copy
63
    ///                        should be created.
64
    ///
65
    /// \tparam  The only template argument specifies the component type to
66
    ///          create.
67
    ///
68
    /// \returns A future representing the global id of the newly (copied)
69
    ///          component instance.
70
    ///
71
    template <typename Component>
72
#if defined(DOXYGEN)
73
    future<hpx::id_type>
74
#else
75
    std::enable_if_t<traits::is_component_v<Component>, future<hpx::id_type>>
76
#endif
77
    copy(hpx::id_type const& to_copy, hpx::id_type const& target_locality)
78
    {
79
        using action_type = server::copy_component_action<Component>;
80
        return hpx::detail::async_colocated<action_type>(
81
            to_copy, to_copy, target_locality);
82
    }
83

84
    ///////////////////////////////////////////////////////////////////////////
85
    /// \brief Copy given component to the specified target locality
86
    ///
87
    /// The function \a copy will create a copy of the component
88
    /// referenced by the client side object \a to_copy on the locality
89
    /// specified with \a target_locality. It returns a new client side object
90
    /// future referring to the newly created component instance.
91
    ///
92
    /// \param to_copy         [in] The client side object representing the
93
    ///                        component to copy
94
    /// \param target_locality [in, optional] The locality where the copy
95
    ///                        should be created (default is same locality
96
    ///                        as source).
97
    ///
98
    /// \tparam  The only template argument specifies the component type to
99
    ///          create.
100
    ///
101
    /// \returns A future representing the global id of the newly (copied)
102
    ///          component instance.
103
    ///
104
    /// \note If the second argument is omitted (or is invalid_id) the
105
    ///       new component instance is created on the locality of the
106
    ///       component instance which is to be copied.
107
    ///
108
    template <typename Derived, typename Stub, typename Data>
109
    Derived copy(client_base<Derived, Stub, Data> const& to_copy,
110
        hpx::id_type const& target_locality = hpx::invalid_id)
111
    {
112
        using component_type =
113
            typename client_base<Derived, Stub, Data>::server_component_type;
114
        using action_type = server::copy_component_action<component_type>;
115

116
        return Derived(hpx::detail::async_colocated<action_type>(
117
            to_copy, to_copy, target_locality));
118
    }
119
}    // namespace hpx::components
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