• 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

20.0
/libs/full/runtime_components/include/hpx/runtime_components/create_component_helpers.hpp
1
//  Copyright (c) 2020-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
#pragma once
8

9
#include <hpx/config.hpp>
10
#include <hpx/async_colocated/async_colocated_fwd.hpp>
11
#include <hpx/async_distributed/detail/async_implementations_fwd.hpp>
12
#include <hpx/modules/async_local.hpp>
13
#include <hpx/modules/errors.hpp>
14
#include <hpx/modules/futures.hpp>
15
#include <hpx/naming_base/id_type.hpp>
16

17
#include <cstddef>
18
#include <type_traits>
19
#include <utility>
20
#include <vector>
21

22
///////////////////////////////////////////////////////////////////////////////
23
namespace hpx::components {
24

25
    namespace server {
26

27
        template <typename Component, typename... Ts>
28
        struct create_component_action;
29

30
        template <bool WithCount, typename Component, typename... Ts>
31
        struct bulk_create_component_action;
32
    }    // namespace server
33

34
    ///////////////////////////////////////////////////////////////////////////
35
    /// Asynchronously create a new instance of a component
36
    template <typename Component, typename... Ts>
37
    future<hpx::id_type> create_async(hpx::id_type const& gid, Ts&&... vs)
×
38
    {
39
        if (!naming::is_locality(gid))
40
        {
41
            HPX_THROW_EXCEPTION(hpx::error::bad_parameter,
×
42
                "stubs::runtime_support::create_component_async",
43
                "The id passed as the first argument is not representing "
44
                "a locality");
45
        }
46

47
        using action_type =
48
            server::create_component_action<Component, std::decay_t<Ts>...>;
49

50
        return hpx::async<action_type>(gid, HPX_FORWARD(Ts, vs)...);
51
    }
52

53
    template <bool WithCount, typename Component, typename... Ts>
54
    future<std::vector<hpx::id_type>> bulk_create_async(
55
        hpx::id_type const& gid, std::size_t count, Ts&&... vs)
1✔
56
    {
57
        if (!naming::is_locality(gid))
58
        {
59
            HPX_THROW_EXCEPTION(hpx::error::bad_parameter,
60
                "stubs::runtime_support::bulk_create_component_async",
×
61
                "The id passed as the first argument is not representing "
62
                "a locality");
63
        }
64

65
        using action_type = server::bulk_create_component_action<WithCount,
66
            Component, std::decay_t<Ts>...>;
67

68
        return hpx::async<action_type>(gid, count, HPX_FORWARD(Ts, vs)...);
69
    }
70

71
    template <typename Component, typename... Ts>
72
    hpx::id_type create(hpx::id_type const& gid, Ts&&... vs)
73
    {
74
        return create_async<Component>(gid, HPX_FORWARD(Ts, vs)...).get();
75
    }
76

77
    template <bool WithCount, typename Component, typename... Ts>
78
    std::vector<hpx::id_type> bulk_create(
79
        hpx::id_type const& gid, std::size_t count, Ts&&... vs)
80
    {
81
        return bulk_create_async<WithCount, Component>(
82
            gid, count, HPX_FORWARD(Ts, vs)...)
83
            .get();
84
    }
85

86
    template <typename Component, typename... Ts>
87
    future<hpx::id_type> create_colocated_async(
88
        hpx::id_type const& gid, Ts&&... vs)
89
    {
90
        using action_type =
91
            server::create_component_action<Component, std::decay_t<Ts>...>;
92

93
        return hpx::detail::async_colocated<action_type>(
94
            gid, HPX_FORWARD(Ts, vs)...);
95
    }
×
96

97
    template <typename Component, typename... Ts>
98
    static hpx::id_type create_colocated(hpx::id_type const& gid, Ts&&... vs)
99
    {
100
        return create_colocated_async(gid, HPX_FORWARD(Ts, vs)...).get();
101
    }
102

103
    template <bool WithCount, typename Component, typename... Ts>
104
    static future<std::vector<hpx::id_type>> bulk_create_colocated_async(
105
        hpx::id_type const& gid, std::size_t count, Ts&&... vs)
106
    {
107
        using action_type = server::bulk_create_component_action<WithCount,
108
            Component, std::decay_t<Ts>...>;
109

110
        return hpx::detail::async_colocated<action_type>(
111
            gid, count, HPX_FORWARD(Ts, vs)...);
112
    }
113

114
    template <bool WithCount, typename Component, typename... Ts>
115
    std::vector<hpx::id_type> bulk_create_colocated(
116
        hpx::id_type const& id, std::size_t count, Ts&&... vs)
117
    {
118
        return bulk_create_colocated_async<WithCount, Component>(
119
            id, count, HPX_FORWARD(Ts, vs)...)
120
            .get();
121
    }
122
}    // 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