Skip to content

Commit

Permalink
Cleaning up copy_component facility
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jan 23, 2025
1 parent 964ccb0 commit 1d94cbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2021 Hartmut Kaiser
// Copyright (c) 2007-2025 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -19,7 +19,7 @@

#include <type_traits>

namespace hpx { namespace components {
namespace hpx::components {

/// \brief Copy given component to the specified target locality
///
Expand All @@ -43,8 +43,7 @@ namespace hpx { namespace components {
#if defined(DOXYGEN)
future<hpx::id_type>
#else
inline typename std::enable_if<traits::is_component<Component>::value,
future<hpx::id_type>>::type
std::enable_if_t<traits::is_component_v<Component>, future<hpx::id_type>>
#endif
copy(hpx::id_type const& to_copy)
{
Expand Down Expand Up @@ -73,8 +72,7 @@ namespace hpx { namespace components {
#if defined(DOXYGEN)
future<hpx::id_type>
#else
inline typename std::enable_if<traits::is_component<Component>::value,
future<hpx::id_type>>::type
std::enable_if_t<traits::is_component_v<Component>, future<hpx::id_type>>
#endif
copy(hpx::id_type const& to_copy, hpx::id_type const& target_locality)
{
Expand Down Expand Up @@ -115,8 +113,7 @@ namespace hpx { namespace components {
typename client_base<Derived, Stub, Data>::server_component_type;
using action_type = server::copy_component_action<component_type>;

id_type id = to_copy.get_id();
return Derived(hpx::detail::async_colocated<action_type>(
to_copy, to_copy, target_locality));
}
}} // namespace hpx::components
} // namespace hpx::components
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2021 Hartmut Kaiser
// Copyright (c) 2007-2025 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -16,7 +16,7 @@

#include <memory>

namespace hpx { namespace components { namespace server {
namespace hpx::components::server {

///////////////////////////////////////////////////////////////////////////
/// \brief Copy given component to the specified target locality
Expand Down Expand Up @@ -49,8 +49,10 @@ namespace hpx { namespace components { namespace server {
hpx::components::server::runtime_support* rts =
hpx::get_runtime_support_ptr();

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

return runtime_support::copy_create_component<Component>(
Expand All @@ -60,13 +62,11 @@ namespace hpx { namespace components { namespace server {

///////////////////////////////////////////////////////////////////////////
template <typename Component>
future<hpx::id_type> copy_component_here(hpx::id_type const& to_copy)
hpx::id_type copy_component_here(hpx::id_type const& to_copy)
{
future<std::shared_ptr<Component>> f = get_ptr<Component>(to_copy);
return f.then(
[=](future<std::shared_ptr<Component>> f) -> hpx::id_type {
return detail::copy_component_here_postproc(f.get());
});
std::shared_ptr<Component> sp =
get_ptr<Component>(hpx::launch::sync, to_copy);
return detail::copy_component_here_postproc(HPX_MOVE(sp));
}

template <typename Component>
Expand All @@ -75,15 +75,15 @@ namespace hpx { namespace components { namespace server {
{
future<std::shared_ptr<Component>> f = get_ptr<Component>(to_copy);
return f.then(
[=](future<std::shared_ptr<Component>> f) -> hpx::id_type {
[=](future<std::shared_ptr<Component>>&& fsp) -> hpx::id_type {
return detail::copy_component_postproc(
f.get(), target_locality);
fsp.get(), target_locality);
});
}

template <typename Component>
struct copy_component_action_here
: ::hpx::actions::action<future<hpx::id_type> (*)(hpx::id_type const&),
: ::hpx::actions::action<hpx::id_type (*)(hpx::id_type const&),
&copy_component_here<Component>,
copy_component_action_here<Component>>
{
Expand All @@ -96,4 +96,4 @@ namespace hpx { namespace components { namespace server {
&copy_component<Component>, copy_component_action<Component>>
{
};
}}} // namespace hpx::components::server
} // namespace hpx::components::server

0 comments on commit 1d94cbc

Please sign in to comment.