Skip to content

Commit

Permalink
Using bind_action in hpx::init, removing obsolete hand crafted action…
Browse files Browse the repository at this point in the history
…_wrapper2, this fixes #236: Allow binding hpx::util::functions to actions

git-svn-id: https://svn.cct.lsu.edu/repos/projects/parallex/trunk/hpx@7738 5079c8e4-9419-0410-93bb-9e5ee278c886
  • Loading branch information
hkaiser committed Apr 14, 2012
1 parent 217b35a commit a7b8c5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 42 deletions.
4 changes: 2 additions & 2 deletions hpx/util/bind_action.hpp
Expand Up @@ -320,7 +320,7 @@ namespace hpx { namespace util
hpx::applier::apply<Action>( \
hpx::util::detail::eval(env, arg0) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(NN)) \
BOOST_PP_ENUM_SHIFTED(NN, HPX_UTIL_BIND_EVAL, _)).get(); \
BOOST_PP_ENUM_SHIFTED(NN, HPX_UTIL_BIND_EVAL, _)); \
} \
template <BOOST_PP_ENUM_PARAMS(N, typename A)> \
void operator()(BOOST_PP_ENUM(N, HPX_UTIL_BIND_FWD_REF_PARAMS, _)) const \
Expand All @@ -334,7 +334,7 @@ namespace hpx { namespace util
hpx::applier::apply<Action>( \
hpx::util::detail::eval(env, arg0) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(NN)) \
BOOST_PP_ENUM_SHIFTED(NN, HPX_UTIL_BIND_EVAL, _)).get(); \
BOOST_PP_ENUM_SHIFTED(NN, HPX_UTIL_BIND_EVAL, _)); \
} \
/**/
BOOST_PP_REPEAT_FROM_TO(
Expand Down
49 changes: 9 additions & 40 deletions src/hpx_init.cpp
Expand Up @@ -14,6 +14,7 @@
#include <hpx/util/sed_transform.hpp>
#include <hpx/util/parse_command_line.hpp>
#include <hpx/util/manage_config.hpp>
#include <hpx/util/bind_action.hpp>

#include <hpx/lcos/async.hpp>
#include <hpx/runtime/components/runtime_support.hpp>
Expand Down Expand Up @@ -61,44 +62,6 @@ HPX_PLAIN_ACTION_EX(hpx::detail::list_component_type, list_component_type_action

namespace hpx { namespace detail
{
///////////////////////////////////////////////////////////////////////////
// Functional wrapper for any action2
template <typename Action>
struct action_wrapper2
{
typedef typename boost::add_const<
typename Action::arguments_type
>::type arguments_type;

typedef typename
boost::fusion::result_of::at_c<arguments_type, 0>::type
arg1_type;
typedef typename
boost::fusion::result_of::at_c<arguments_type, 1>::type
arg2_type;

// default constructor is required for serialization
action_wrapper2()
{}

action_wrapper2(naming::id_type const& target)
: target_(target)
{}

void operator() (arg1_type s, arg2_type t) const
{
applier::apply<Action>(target_, s, t);
}

template <typename Archive>
void serialize(Archive& ar, unsigned /*version*/)
{
ar & target_;
}

naming::id_type target_;
};

///////////////////////////////////////////////////////////////////////////
// print string on the console
void console_print(std::string const& name)
Expand Down Expand Up @@ -195,9 +158,12 @@ namespace hpx { namespace detail
print(std::string("List of all registered symbolic names:"));
print(std::string(78, '-'));

using hpx::util::placeholders::_1;
using hpx::util::placeholders::_2;

naming::id_type console(agas::get_console_locality());
naming::get_agas_client().iterate_ids(
action_wrapper2<list_symbolic_name_action>(console));
hpx::util::bind<list_symbolic_name_action>(console, _1, _2));
}

///////////////////////////////////////////////////////////////////////////
Expand All @@ -213,9 +179,12 @@ namespace hpx { namespace detail
print(std::string("List of all registered component types:"));
print(std::string(78, '-'));

using hpx::util::placeholders::_1;
using hpx::util::placeholders::_2;

naming::id_type console(agas::get_console_locality());
naming::get_agas_client().iterate_types(
action_wrapper2<list_component_type_action>(console));
hpx::util::bind<list_component_type_action>(console, _1, _2));
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit a7b8c5c

Please sign in to comment.