-
-
Save hkaiser/3057182 to your computer and use it in GitHub Desktop.
register functor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hpx/hpx.hpp> | |
#include <hpx/hpx_init.hpp> | |
#include <hpx/runtime/actions/plain_action.hpp> | |
#include <hpx/components/dataflow/dataflow.hpp> | |
#include <iostream> | |
#include <cstdlib> | |
template<class T> | |
struct add_ | |
{ | |
typedef T result_type; | |
T operator()(T const& a, T const& b) | |
{ | |
return a+b; | |
} | |
}; | |
typedef hpx::actions:: | |
plain_result_action2< int | |
, int const& | |
, int const& | |
, add_<int> | |
> add_action; | |
HPX_REGISTER_PLAIN_ACTION(add_action); | |
int hpx_main() | |
{ | |
using hpx::lcos::dataflow; | |
using hpx::lcos::dataflow_base; | |
hpx::naming::id_type here = hpx::find_here(); | |
dataflow_base<int> flow = dataflow<add_action>(here, 3, 2); | |
int result = flow.get_future().get(); | |
std::cout << "Result: " << result << std::endl; | |
return hpx::finalize(); | |
} | |
int main(int argc, char **argv) | |
{ | |
return hpx::init(argc, argv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment