Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <hpx/hpx_main.hpp>
- #include <hpx/include/lcos.hpp>
- #include <hpx/include/actions.hpp>
- #include <hpx/include/components.hpp>
- #include <hpx/include/iostreams.hpp>
- #include <boost/format.hpp>
- #include <cstddef>
- #include <list>
- #include <mutex>
- #include <set>
- #include <vector>
- //#include "../../common.h"
- int total_tasks;
- void task_worker(std::size_t id)
- {
- printf("task: %d\n", id);
- }
- HPX_PLAIN_ACTION(task_worker, task_worker_action);
- hpx::future<void> task_foreman()
- {
- std::size_t id = 0;
- hpx::naming::id_type const here = hpx::find_here();
- std::vector<hpx::lcos::future<void> > futures;
- futures.reserve(total_tasks);
- typedef task_worker_action action_type;
- futures.push_back(hpx::async<action_type>(here, id) );
- for(id = 1; id < total_tasks; id++) {
- typedef task_worker_action action_type;
- futures.push_back(futures[id-1].then( hpx::async<action_type>(here, id) ));
- }
- return hpx::when_all(futures);
- }
- HPX_PLAIN_ACTION(task_foreman, task_foreman_action);
- int main(int argc, char **argv)
- {
- total_tasks = 4;
- std::vector<hpx::id_type> localities = hpx::find_all_localities();
- std::vector<hpx::future<void> > futures;
- futures.reserve(localities.size());
- for (hpx::id_type const& node : localities)
- {
- typedef task_foreman_action action_type;
- futures.push_back(hpx::async<action_type>(node));
- }
- hpx::wait_all(futures);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement