Skip to content

Commit

Permalink
Remove redundant action template class
Browse files Browse the repository at this point in the history
  • Loading branch information
K-ballo committed Feb 9, 2019
1 parent d61126b commit d876e24
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 41 deletions.
22 changes: 4 additions & 18 deletions hpx/runtime/actions/basic_action.hpp
Expand Up @@ -461,6 +461,8 @@ namespace hpx { namespace actions
return static_cast<int>(components::get_component_type<Component>());
}

typedef std::false_type direct_execution;

/// The function \a get_action_type returns whether this action needs
/// to be executed in a new thread or directly.
static base_action::action_type get_action_type()
Expand Down Expand Up @@ -521,30 +523,14 @@ namespace hpx { namespace actions
};
}

///////////////////////////////////////////////////////////////////////////
template <typename Signature, typename TF, TF F, typename Derived>
class basic_action_impl;

///////////////////////////////////////////////////////////////////////////
template <typename TF, TF F, typename Derived = detail::this_type>
struct action
: basic_action_impl<TF, TF, F,
typename detail::action_type<
action<TF, F, Derived>,
Derived
>::type>
{
typedef typename detail::action_type<
action, Derived
>::type derived_type;

typedef std::false_type direct_execution;
};
struct action;

///////////////////////////////////////////////////////////////////////////
template <typename TF, TF F, typename Derived = detail::this_type>
struct direct_action
: basic_action_impl<TF, TF, F,
: action<TF, F,
typename detail::action_type<
direct_action<TF, F, Derived>,
Derived
Expand Down
40 changes: 28 additions & 12 deletions hpx/runtime/actions/component_action.hpp
Expand Up @@ -87,15 +87,23 @@ namespace hpx { namespace actions
///////////////////////////////////////////////////////////////////////////
template <
typename Component, typename R, typename ...Ps,
typename TF, TF F, typename Derived>
class basic_action_impl<R (Component::*)(Ps...), TF, F, Derived>
: public basic_action<Component, R(Ps...), Derived>
R (Component::*F)(Ps...), typename Derived>
struct action<R (Component::*)(Ps...), F, Derived>
: basic_action<Component, R(Ps...),
typename detail::action_type<
action<R (Component::*)(Ps...), F, Derived>,
Derived
>::type
>
{
public:
typedef typename detail::action_type<
action, Derived
>::type derived_type;

static std::string get_action_name(naming::address::address_type lva)
{
return detail::make_component_action_name(
detail::get_action_name<Derived>(),
detail::get_action_name<derived_type>(),
get_lva<Component>::call(lva));
}

Expand All @@ -104,7 +112,7 @@ namespace hpx { namespace actions
naming::address::address_type lva,
naming::address::component_type comptype, Ts&&... vs)
{
basic_action<Component, R(Ps...), Derived>::
basic_action<Component, R(Ps...), derived_type>::
increment_invocation_count();

using is_future = typename traits::is_future<R>::type;
Expand All @@ -119,15 +127,23 @@ namespace hpx { namespace actions
///////////////////////////////////////////////////////////////////////////
template <
typename Component, typename R, typename ...Ps,
typename TF, TF F, typename Derived>
class basic_action_impl<R (Component::*)(Ps...) const, TF, F, Derived>
: public basic_action<Component const, R(Ps...), Derived>
R (Component::*F)(Ps...) const, typename Derived>
struct action<R (Component::*)(Ps...) const, F, Derived>
: basic_action<Component const, R(Ps...),
typename detail::action_type<
action<R (Component::*)(Ps...) const, F, Derived>,
Derived
>::type
>
{
public:
typedef typename detail::action_type<
action, Derived
>::type derived_type;

static std::string get_action_name(naming::address::address_type lva)
{
return detail::make_component_action_name(
detail::get_action_name<Derived>(),
detail::get_action_name<derived_type>(),
get_lva<Component>::call(lva));
}

Expand All @@ -136,7 +152,7 @@ namespace hpx { namespace actions
naming::address::address_type lva,
naming::address::component_type comptype, Ts&&... vs)
{
basic_action<Component const, R(Ps...), Derived>::
basic_action<Component const, R(Ps...), derived_type>::
increment_invocation_count();

using is_future = typename traits::is_future<R>::type;
Expand Down
2 changes: 0 additions & 2 deletions hpx/runtime/actions/lambda_to_action.hpp
Expand Up @@ -43,8 +43,6 @@ namespace hpx { namespace actions
lambda_action<F, ReturnType, Args...>>
{
typedef lambda_action derived_type;
typedef std::false_type direct_execution;
typedef void is_plain_action;

static std::string get_action_name(naming::address::address_type /*lva*/)
{
Expand Down
20 changes: 14 additions & 6 deletions hpx/runtime/actions/plain_action.hpp
Expand Up @@ -63,23 +63,31 @@ namespace hpx { namespace actions
///////////////////////////////////////////////////////////////////////////
template <
typename R, typename ...Ps,
typename TF, TF F, typename Derived>
class basic_action_impl<R (*)(Ps...), TF, F, Derived>
: public basic_action<detail::plain_function, R(Ps...), Derived>
R (*F)(Ps...), typename Derived>
struct action<R (*)(Ps...), F, Derived>
: basic_action<detail::plain_function, R(Ps...),
typename detail::action_type<
action<R (*)(Ps...), F, Derived>,
Derived
>::type
>
{
public:
typedef typename detail::action_type<
action, Derived
>::type derived_type;

static std::string get_action_name(naming::address::address_type /*lva*/)
{
return detail::make_plain_action_name(
detail::get_action_name<Derived>());
detail::get_action_name<derived_type>());
}

template <typename ...Ts>
static R invoke(
naming::address::address_type /*lva*/,
naming::address::component_type comptype, Ts&&... vs)
{
basic_action<detail::plain_function, R(Ps...), Derived>::
basic_action<detail::plain_function, R(Ps...), derived_type>::
increment_invocation_count();
return F(std::forward<Ts>(vs)...);
}
Expand Down
4 changes: 1 addition & 3 deletions hpx/runtime/components/server/console_error_sink.hpp
Expand Up @@ -20,9 +20,7 @@ namespace hpx { namespace components { namespace server
// console logging happens here
void console_error_sink(std::exception_ptr const&);

typedef actions::action<
void (*)(std::exception_ptr const&), console_error_sink
> console_error_sink_action;
HPX_DEFINE_PLAIN_ACTION(console_error_sink, console_error_sink_action);
}}}

HPX_ACTION_HAS_CRITICAL_PRIORITY(
Expand Down

0 comments on commit d876e24

Please sign in to comment.