-
-
Save hkaiser/302b6eb9d688b6cc5e8dfdb26eb39171 to your computer and use it in GitHub Desktop.
This file contains hidden or 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_main.hpp> | |
#include <hpx/hpx.hpp> | |
#include <cstdlib> | |
#include <chrono> | |
int universal_ans(int) | |
{ | |
hpx::this_thread::sleep_for(std::chrono::seconds(5)); | |
return 42; | |
} | |
HPX_PLAIN_ACTION(universal_ans, universal_ans_action); | |
template <typename Action, typename... Ts> | |
int invoker(Ts&&... ts) | |
{ | |
hpx::thread t([&]() {Action{}.invoke(0, 0, std::forward<Ts>(ts)...);}); | |
t.interrupt(); | |
t.join(); | |
return 0; | |
} | |
template <typename Action, typename... Ts> | |
using invoker_action = | |
typename hpx::actions::make_action< | |
decltype(&invoker<Action, Ts...>), | |
&invoker<Action, Ts...> | |
>::type; | |
int main() | |
{ | |
invoker_action<universal_ans_action, int> ac; | |
hpx::future<int> f = hpx::async(ac, hpx::find_here(), 5); | |
f.get(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment