Skip to content

Commit

Permalink
Switching simple_component to be component
Browse files Browse the repository at this point in the history
 - Moving implementation of a simple component to component(_base)
 - Keeping using simple_component = component and friends for backwards
   compatbility.
  • Loading branch information
Thomas Heller committed Aug 22, 2017
1 parent 1839bda commit 938127f
Show file tree
Hide file tree
Showing 12 changed files with 490 additions and 595 deletions.
26 changes: 1 addition & 25 deletions hpx/lcos/base_lco_with_value.hpp
Expand Up @@ -14,7 +14,6 @@
#include <hpx/runtime/components/component_type.hpp>
#include <hpx/runtime/components/server/component.hpp>
#include <hpx/runtime/components/server/managed_component_base.hpp>
#include <hpx/runtime/components/server/simple_component_base.hpp>
#include <hpx/runtime/components_fwd.hpp>
#include <hpx/runtime/naming/id_type.hpp>
#include <hpx/traits/is_component.hpp>
Expand Down Expand Up @@ -46,12 +45,6 @@ namespace hpx { namespace lcos
typedef components::component<BaseLco> type;
};

template <typename BaseLco>
struct base_lco_wrapping_type<traits::detail::simple_component_tag, BaseLco>
{
typedef components::simple_component<BaseLco> type;
};

template <typename BaseLco>
struct base_lco_wrapping_type<traits::detail::managed_component_tag, BaseLco>
{
Expand Down Expand Up @@ -201,24 +194,7 @@ namespace hpx { namespace traits
{
static components::component_type get()
{
return components::component_base_lco_with_value_unmanaged;
}

static void set(components::component_type)
{
HPX_ASSERT(false);
}
};

template <typename Result, typename RemoteResult, typename Enable>
struct component_type_database<
hpx::lcos::base_lco_with_value<
Result, RemoteResult, traits::detail::simple_component_tag
>, Enable>
{
static components::component_type get()
{
return components::component_base_lco_with_value_simple_unmanaged;
return components::component_base_lco_with_value;
}

static void set(components::component_type)
Expand Down
304 changes: 157 additions & 147 deletions hpx/performance_counters/server/base_performance_counter.hpp
Expand Up @@ -19,153 +19,163 @@
///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace performance_counters { namespace server
{
class base_performance_counter
: public hpx::performance_counters::performance_counter_base
, public hpx::traits::detail::simple_component_tag
{
protected:
/// the following functions are not implemented by default, they will
/// just throw
virtual void reset_counter_value()
{
HPX_THROW_EXCEPTION(invalid_status, "reset_counter_value",
"reset_counter_value is not implemented for this counter");
}

virtual void set_counter_value(counter_value const& /*value*/)
{
HPX_THROW_EXCEPTION(invalid_status, "set_counter_value",
"set_counter_value is not implemented for this counter");
}

virtual counter_value get_counter_value(bool reset)
{
HPX_THROW_EXCEPTION(invalid_status, "get_counter_value",
"get_counter_value is not implemented for this counter");
return counter_value();
}

virtual counter_values_array get_counter_values_array(bool reset)
{
HPX_THROW_EXCEPTION(invalid_status, "get_counter_values_array",
"get_counter_values_array is not implemented for this counter");
return counter_values_array();
}

virtual bool start()
{
return false; // nothing to do
}

virtual bool stop()
{
return false; // nothing to do
}

virtual counter_info get_counter_info() const
{
return info_;
}

public:
base_performance_counter() : invocation_count_(0) {}
base_performance_counter(counter_info const& info)
: info_(info), invocation_count_(0)
{}

// components must contain a typedef for wrapping_type defining the
// component type used to encapsulate instances of this
// component
typedef components::component<base_performance_counter> wrapping_type;
typedef base_performance_counter base_type_holder;

/// \brief finalize() will be called just before the instance gets
/// destructed
void finalize() {}

static components::component_type get_component_type()
{
return components::get_component_type<wrapping_type>();
}
static void set_component_type(components::component_type t)
{
components::set_component_type<wrapping_type>(t);
}

///////////////////////////////////////////////////////////////////////
counter_info get_counter_info_nonvirt() const
{
return this->get_counter_info();
}

counter_value get_counter_value_nonvirt(bool reset)
{
return this->get_counter_value(reset);
}

counter_values_array get_counter_values_array_nonvirt(bool reset)
{
return this->get_counter_values_array(reset);
}

void set_counter_value_nonvirt(counter_value const& info)
{
this->set_counter_value(info);
}

void reset_counter_value_nonvirt()
{
this->reset_counter_value();
}

bool start_nonvirt()
{
return this->start();
}

bool stop_nonvirt()
{
return this->stop();
}

/// Each of the exposed functions needs to be encapsulated into an action
/// type, allowing to generate all required boilerplate code for threads,
/// serialization, etc.

/// The \a get_counter_info_action retrieves a performance counters
/// information.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_info_nonvirt, get_counter_info_action);

/// The \a get_counter_value_action queries the value of a performance
/// counter.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_value_nonvirt, get_counter_value_action);

/// The \a get_counter_value_action queries the value of a performance
/// counter.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_values_array_nonvirt, get_counter_values_array_action);

/// The \a set_counter_value_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
set_counter_value_nonvirt, set_counter_value_action);

/// The \a reset_counter_value_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
reset_counter_value_nonvirt, reset_counter_value_action);

/// The \a start_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
start_nonvirt, start_action);

/// The \a stop_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
stop_nonvirt, stop_action);

protected:
hpx::performance_counters::counter_info info_;
util::atomic_count invocation_count_;
class base_performance_counter
: public hpx::performance_counters::performance_counter_base,
public hpx::traits::detail::component_tag
{
protected:
/// the following functions are not implemented by default, they will
/// just throw
virtual void reset_counter_value()
{
HPX_THROW_EXCEPTION(invalid_status, "reset_counter_value",
"reset_counter_value is not implemented for this counter");
}

virtual void set_counter_value(counter_value const& /*value*/)
{
HPX_THROW_EXCEPTION(invalid_status, "set_counter_value",
"set_counter_value is not implemented for this counter");
}

virtual counter_value get_counter_value(bool reset)
{
HPX_THROW_EXCEPTION(invalid_status, "get_counter_value",
"get_counter_value is not implemented for this counter");
return counter_value();
}

virtual counter_values_array get_counter_values_array(bool reset)
{
HPX_THROW_EXCEPTION(invalid_status, "get_counter_values_array",
"get_counter_values_array is not implemented for this "
"counter");
return counter_values_array();
}

virtual bool start()
{
return false; // nothing to do
}

virtual bool stop()
{
return false; // nothing to do
}

virtual counter_info get_counter_info() const
{
return info_;
}

public:
base_performance_counter()
: invocation_count_(0)
{
}
base_performance_counter(counter_info const& info)
: info_(info)
, invocation_count_(0)
{
}

// components must contain a typedef for wrapping_type defining the
// component type used to encapsulate instances of this
// component
typedef components::component<base_performance_counter>
wrapping_type;
typedef base_performance_counter base_type_holder;

/// \brief finalize() will be called just before the instance gets
/// destructed
void finalize()
{
}

static components::component_type get_component_type()
{
return components::get_component_type<wrapping_type>();
}
static void set_component_type(components::component_type t)
{
components::set_component_type<wrapping_type>(t);
}

///////////////////////////////////////////////////////////////////////
counter_info get_counter_info_nonvirt() const
{
return this->get_counter_info();
}

counter_value get_counter_value_nonvirt(bool reset)
{
return this->get_counter_value(reset);
}

counter_values_array get_counter_values_array_nonvirt(bool reset)
{
return this->get_counter_values_array(reset);
}

void set_counter_value_nonvirt(counter_value const& info)
{
this->set_counter_value(info);
}

void reset_counter_value_nonvirt()
{
this->reset_counter_value();
}

bool start_nonvirt()
{
return this->start();
}

bool stop_nonvirt()
{
return this->stop();
}

/// Each of the exposed functions needs to be encapsulated into an action
/// type, allowing to generate all required boilerplate code for threads,
/// serialization, etc.

/// The \a get_counter_info_action retrieves a performance counters
/// information.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_info_nonvirt, get_counter_info_action);

/// The \a get_counter_value_action queries the value of a performance
/// counter.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_value_nonvirt, get_counter_value_action);

/// The \a get_counter_value_action queries the value of a performance
/// counter.
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
get_counter_values_array_nonvirt,
get_counter_values_array_action);

/// The \a set_counter_value_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
set_counter_value_nonvirt, set_counter_value_action);

/// The \a reset_counter_value_action
HPX_DEFINE_COMPONENT_ACTION(base_performance_counter,
reset_counter_value_nonvirt, reset_counter_value_action);

/// The \a start_action
HPX_DEFINE_COMPONENT_ACTION(
base_performance_counter, start_nonvirt, start_action);

/// The \a stop_action
HPX_DEFINE_COMPONENT_ACTION(
base_performance_counter, stop_nonvirt, stop_action);

protected:
hpx::performance_counters::counter_info info_;
util::atomic_count invocation_count_;
};
}}}

Expand Down
14 changes: 0 additions & 14 deletions hpx/runtime/actions/set_lco_value_continuation.hpp
Expand Up @@ -29,20 +29,6 @@ namespace hpx { namespace actions
}
};

///////////////////////////////////////////////////////////////////////////
struct set_lco_value_simple_unmanaged_continuation
{
template <typename T>
HPX_FORCEINLINE T operator()(naming::id_type const& lco, T&& t) const
{
hpx::set_lco_value_simple_unmanaged(lco, std::forward<T>(t));

// Yep, 't' is a zombie, however we don't use the returned value
// anyways. We need it for result type calculation, though.
return std::move(t);
}
};

///////////////////////////////////////////////////////////////////////////
struct set_lco_value_unmanaged_continuation
{
Expand Down

0 comments on commit 938127f

Please sign in to comment.