Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2887 from STEllAR-GROUP/fixing_2885
Adapt broadcast() to non-unwrapping async<Action>
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2017 Hartmut Kaiser | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/include/lcos.hpp> | ||
#include <hpx/lcos/broadcast.hpp> | ||
#include <hpx/util/lightweight_test.hpp> | ||
|
||
#include <vector> | ||
|
||
hpx::future<void> bcast_void(double bcast) | ||
{ | ||
return hpx::make_ready_future(); | ||
} | ||
|
||
HPX_PLAIN_ACTION(bcast_void); | ||
|
||
HPX_REGISTER_BROADCAST_ACTION_DECLARATION(bcast_void_action) | ||
HPX_REGISTER_BROADCAST_ACTION(bcast_void_action) | ||
|
||
hpx::future<double> bcast(double bcast) | ||
{ | ||
return hpx::make_ready_future(bcast); | ||
} | ||
|
||
HPX_PLAIN_ACTION(bcast); | ||
|
||
HPX_REGISTER_BROADCAST_ACTION_DECLARATION(bcast_action) | ||
HPX_REGISTER_BROADCAST_ACTION(bcast_action) | ||
|
||
int hpx_main() | ||
{ | ||
std::vector<hpx::id_type> localities = hpx::find_all_localities(); | ||
|
||
auto f1 = hpx::lcos::broadcast<bcast_void_action>(localities, 42.0); | ||
f1.get(); | ||
|
||
auto f2 = hpx::lcos::broadcast<bcast_action>(localities, 42.0); | ||
for (hpx::future<double>& f : f2.get()) | ||
{ | ||
HPX_TEST_EQ(42.0, f.get()); | ||
} | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
HPX_TEST_EQ(hpx::init(argc, argv), 0); | ||
return hpx::util::report_errors(); | ||
} | ||
|