• 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/async_colocated/src/server/destroy_component.cpp
1
//  Copyright (c) 2007-2023 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
#include <hpx/config.hpp>
8
#include <hpx/actions_base/plain_action.hpp>
9
#include <hpx/async_colocated/get_colocation_id.hpp>
10
#include <hpx/async_colocated/server/destroy_component.hpp>
11
#include <hpx/components_base/agas_interface.hpp>
12
#include <hpx/components_base/detail/agas_interface_functions.hpp>
13
#include <hpx/modules/async_distributed.hpp>
14
#include <hpx/modules/logging.hpp>
15
#include <hpx/modules/type_support.hpp>
16
#include <hpx/naming_base/id_type.hpp>
17

18
#include <cstddef>
19
#include <cstdint>
20

×
21
#include <hpx/config/warnings_prefix.hpp>
22

23
HPX_PLAIN_ACTION_ID(hpx::components::server::destroy_component,
24
    hpx_destroy_component_action, hpx::actions::free_component_action_id)
25

26
///////////////////////////////////////////////////////////////////////////////
27
namespace hpx::components::server {
×
28

29
    ///////////////////////////////////////////////////////////////////////////
30
    void destroy_component(
31
        naming::gid_type const& gid, naming::address const& addr_)
32
    {
×
33
        naming::address addr(addr_);
×
34
        if (naming::get_locality_id_from_gid(addr.locality_) ==
35
                agas::get_locality_id() ||
36
            agas::is_local_address_cached(gid, addr))
37
        {
38
            // Check if component was migrated, we are not interested in pinning
39
            // the object as it is supposed to be destroyed anyway - that is, no
40
            // one else has a handle to it anymore
×
41

×
42
            // The object is local, we can destroy it locally...
×
43
            if (auto const r = agas::was_object_migrated(
44
                    gid, []() { return pinned_ptr(); });
×
45
                !r.first)
46
            {
47
                if (naming::refers_to_virtual_memory(gid))
×
48
                {
×
49
                    // simply delete the memory
50
                    delete[] hpx::bit_cast<std::uint8_t*>(
51
                        static_cast<std::size_t>(gid.get_lsb()));
×
52
                    return;
53
                }
×
54

55
                components::deleter(addr.type_)(gid, addr);
×
56

57
                LRT_(info).format(
×
58
                    "successfully destroyed component {} of type: {}", gid,
59
                    components::get_component_type_name(addr.type_));
60

61
                return;
62
            }
63
        }
×
64

65
        // apply remotely (only if runtime is not stopping)
66
        hpx::id_type const id = get_colocation_id(launch::sync,
67
            hpx::id_type(gid, hpx::id_type::management_type::unmanaged));
68

69
        hpx_destroy_component_action()(id, gid, addr);
70
    }
71

72
    ///////////////////////////////////////////////////////////////////////////
73
    // initialize AGAS interface function pointers in components_base module
74
    struct HPX_EXPORT destroy_interface_function
75
    {
76
        destroy_interface_function()
77
        {
78
            agas::detail::destroy_component = &destroy_component;
79
        }
80
    };
81

82
    destroy_interface_function destroy_init;
83
}    // 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

© 2025 Coveralls, Inc