Skip to content

Commit

Permalink
Merge pull request #2723 from STEllAR-GROUP/fixing_2722
Browse files Browse the repository at this point in the history
Enable lcos::channel<T>::register_as
  • Loading branch information
hkaiser committed Jul 3, 2017
2 parents 25d5634 + b0c5c98 commit 93f4496
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hpx/runtime/components/client_base.hpp
Expand Up @@ -526,7 +526,7 @@ namespace hpx { namespace components

private:
///////////////////////////////////////////////////////////////////////
static void register_as_helper(Derived && f,
static void register_as_helper(client_base const& f,
std::string const& symbolic_name)
{
hpx::agas::register_name(launch::sync, symbolic_name, f.get());
Expand Down
1 change: 1 addition & 0 deletions tests/regressions/lcos/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ set(tests
async_unwrap_1037
barrier_hang
call_promise_get_gid_more_than_once
channel_register_as_2722
dataflow_791
dataflow_action_2008
dataflow_const_functor_773
Expand Down
47 changes: 47 additions & 0 deletions tests/regressions/lcos/channel_register_as_2722.cpp
@@ -0,0 +1,47 @@
// Copyright (c) 2017 Zach Byerly
//
// 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.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/util/lightweight_test.hpp>

HPX_REGISTER_CHANNEL(int); // add to one source file

void send_values(hpx::lcos::channel<int> buffer)
{
buffer.set(hpx::launch::sync, 42);
buffer.set(hpx::launch::sync, 42);
}

void receive_values()
{
hpx::lcos::channel<int> buffer;
buffer.connect_to("my_channel");

HPX_TEST_EQ(42, buffer.get(hpx::launch::sync));
HPX_TEST_EQ(42, buffer.get(hpx::launch::sync));
}

int hpx_main(int argc, char **argv)
{
{
hpx::lcos::channel<int> buffer(hpx::find_here());
buffer.register_as("my_channel");

hpx::future<void> f1 = hpx::async(&send_values, buffer);
hpx::future<void> f2 = hpx::async(&receive_values);

hpx::wait_all(f1, f2);

} // unregisters 'buffer'

return hpx::finalize();
}

int main(int argc, char **argv)
{
HPX_TEST_EQ(0, hpx::init(argc, argv));
return hpx::util::report_errors();
}

0 comments on commit 93f4496

Please sign in to comment.