• 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/server/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
#pragma once
8

9
#include <hpx/config.hpp>
10
#include <hpx/actions_base/plain_action.hpp>
11
#include <hpx/components/get_ptr.hpp>
12
#include <hpx/modules/futures.hpp>
13
#include <hpx/naming_base/id_type.hpp>
14
#include <hpx/runtime_components/components_fwd.hpp>
15
#include <hpx/runtime_distributed/stubs/runtime_support.hpp>
16

17
#include <memory>
18

19
namespace hpx::components::server {
20

21
    ///////////////////////////////////////////////////////////////////////////
22
    /// \brief Copy given component to the specified target locality
23
    namespace detail {
24
        // If we know that the new component has to be created local to the old
25
        // one, we can avoid doing serialization.
26
        template <typename Component>
27
        hpx::id_type copy_component_here_postproc(
×
28
            std::shared_ptr<Component> ptr)
29
        {
30
            // This is executed on the locality where the component lives.
31
            hpx::components::server::runtime_support* rts =
32
                hpx::get_runtime_support_ptr();
×
33

34
            return traits::get_remote_result<id_type, naming::gid_type>::call(
35
                rts->copy_create_component<Component>(ptr, true));
×
36
        }
37

38
        template <typename Component>
39
        hpx::id_type copy_component_postproc(
40
            std::shared_ptr<Component> ptr, hpx::id_type const& target_locality)
41
        {
42
            using stubs::runtime_support;
43

44
            if (!target_locality || target_locality == find_here())
45
            {
46
                // This is executed on the locality where the component lives,
47
                // if no target_locality is given we have to create the copy on
48
                // the locality of the component.
49
                hpx::components::server::runtime_support* rts =
50
                    hpx::get_runtime_support_ptr();
51

52
                // clang-format off
53
                return traits::get_remote_result<id_type, naming::gid_type>::
54
                    call(rts->copy_create_component<Component>(ptr, true));
55
                // clang-format on
56
            }
57

58
            return runtime_support::copy_create_component<Component>(
59
                target_locality, ptr, false);
60
        }
61
    }    // namespace detail
62

63
    ///////////////////////////////////////////////////////////////////////////
×
64
    template <typename Component>
65
    hpx::id_type copy_component_here(hpx::id_type const& to_copy)
×
66
    {
67
        std::shared_ptr<Component> sp =
×
68
            get_ptr<Component>(hpx::launch::sync, to_copy);
×
69
        return detail::copy_component_here_postproc(HPX_MOVE(sp));
×
70
    }
71

72
    template <typename Component>
73
    future<hpx::id_type> copy_component(
74
        hpx::id_type const& to_copy, hpx::id_type const& target_locality)
75
    {
76
        future<std::shared_ptr<Component>> f = get_ptr<Component>(to_copy);
77
        return f.then(
78
            [=](future<std::shared_ptr<Component>>&& fsp) -> hpx::id_type {
79
                return detail::copy_component_postproc(
80
                    fsp.get(), target_locality);
81
            });
82
    }
83

84
    template <typename Component>
85
    struct copy_component_action_here
86
      : ::hpx::actions::action<hpx::id_type (*)(hpx::id_type const&),
87
            &copy_component_here<Component>,
88
            copy_component_action_here<Component>>
89
    {
90
    };
91

92
    template <typename Component>
93
    struct copy_component_action
94
      : ::hpx::actions::action<future<hpx::id_type> (*)(
95
                                   hpx::id_type const&, hpx::id_type const&),
96
            &copy_component<Component>, copy_component_action<Component>>
97
    {
98
    };
99
}    // namespace hpx::components::server
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