Skip to content

Commit

Permalink
Adding missing component registry for memory_block
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Mar 13, 2018
1 parent 75af87d commit bc77492
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hpx/runtime/components/server/memory_block.hpp
Expand Up @@ -11,6 +11,7 @@
#include <hpx/runtime/actions/component_action.hpp>
#include <hpx/runtime/actions/manage_object_action.hpp>
#include <hpx/runtime/components/component_type.hpp>
#include <hpx/runtime/components/server/destroy_component.hpp>
#include <hpx/runtime/components/server/managed_component_base.hpp>
#include <hpx/runtime/components/server/wrapper_heap.hpp>
#include <hpx/runtime/components/server/wrapper_heap_list.hpp>
Expand Down Expand Up @@ -454,6 +455,7 @@ namespace hpx { namespace components { namespace server
public:
typedef detail::memory_block_header wrapped_type;
typedef memory_block type_holder;
typedef memory_block base_type_holder;

/// \brief Construct an empty managed_component
memory_block()
Expand Down Expand Up @@ -499,6 +501,7 @@ namespace hpx { namespace components { namespace server
component_.reset(p);
}

public:
/// \brief finalize() will be called just before the instance gets
/// destructed
///
Expand Down Expand Up @@ -704,6 +707,42 @@ namespace hpx { namespace components { namespace server
return wrapper_->get_base_gid();
}
}

template <>
inline void destroy<memory_block>(
naming::gid_type const& gid, naming::address const& addr)
{
// make sure this component is located here
components::component_type type =
components::get_component_type<memory_block>();
if (get_locality() != addr.locality_)
{
std::ostringstream strm;
strm << "global id " << gid << " should not have been migrated "
"instance of type: memory_block";
HPX_THROW_EXCEPTION(hpx::unknown_component_address,
"destroy<memory_block>", strm.str());
return;
}

// make sure it's the correct component type
if (!types_are_compatible(type, addr.type_))
{
std::ostringstream strm;
strm << "global id " << gid << " is not bound to a component "
"instance of type: " << get_component_type_name(type)
<< " (it is bound to a " << get_component_type_name(addr.type_)
<< ")";
HPX_THROW_EXCEPTION(hpx::unknown_component_address,
"destroy<memory_block>", strm.str());
return;
}

--instance_count(type);

// delete the local instances
memory_block::destroy(reinterpret_cast<memory_block*>(addr.address_));
}
}}}

namespace hpx { namespace traits
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/components/server/memory_block.cpp
Expand Up @@ -5,6 +5,7 @@

#include <hpx/config.hpp>
#include <hpx/runtime/components/component_factory.hpp>
#include <hpx/runtime/components/component_registry.hpp>
#include <hpx/runtime/components/server/memory_block.hpp>
#include <hpx/runtime/actions/continuation.hpp>
#include <hpx/runtime/actions/manage_object_action.hpp>
Expand Down Expand Up @@ -51,6 +52,11 @@ HPX_REGISTER_BASE_LCO_WITH_VALUE_ID(
hpx::actions::base_lco_with_value_hpx_memory_data_get,
hpx::actions::base_lco_with_value_hpx_memory_data_set)

HPX_DEFINE_COMPONENT_NAME(
hpx::components::server::memory_block, component_memory_block);
HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY(
hpx::components::server::memory_block, component_memory_block);

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace components { namespace server { namespace detail
{
Expand Down
5 changes: 5 additions & 0 deletions src/util/runtime_configuration.cpp
Expand Up @@ -326,6 +326,11 @@ namespace hpx { namespace util
"[hpx.components.elapsed_time_counter]",
"name = hpx",
"path = $[hpx.location]/bin/" HPX_DLL_STRING,
"enabled = 1",

"[hpx.components.component_memory_block]",
"name = hpx",
"path = $[hpx.location]/bin/" HPX_DLL_STRING,
"enabled = 1"
};

Expand Down

0 comments on commit bc77492

Please sign in to comment.