Skip to content

Commit

Permalink
Adding test case for #774: using local dataflow without explicit name…
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
hkaiser committed May 30, 2013
1 parent f3087e0 commit f6477f1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/regressions/lcos/CMakeLists.txt
Expand Up @@ -15,6 +15,11 @@ if(NOT MSVC10)
set(tests ${tests}
dataflow_future_swap
)
if(HPX_HAVE_CXX11_LAMBDAS)
set(tests ${tests}
dataflow_using
)
endif()
endif()

set(async_callback_non_deduced_context_PARAMETERS THREADS_PER_LOCALITY 4)
Expand Down
3 changes: 3 additions & 0 deletions tests/regressions/lcos/dataflow_future_swap.cpp
Expand Up @@ -3,6 +3,9 @@
// 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)

// This test case demonstrates the issue described in #775: runtime error with
// local dataflow (copying futures?).

#include <iostream>

#include <hpx/hpx.hpp>
Expand Down
48 changes: 48 additions & 0 deletions tests/regressions/lcos/dataflow_using.cpp
@@ -0,0 +1,48 @@
// Copyright (c) 2013 Mario Mulanski
//
// 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)

// This test case demonstrates the issue described in #774: using local dataflow
// without explicit namespace.

#include <iostream>

#include <hpx/hpx.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/lcos/local/dataflow.hpp>
#include <hpx/util/unwrap.hpp>

// the following line causes compile errors
using hpx::lcos::local::dataflow;

typedef hpx::lcos::future< double > future_type;

template< typename Value >
struct mul
{
const Value a;

mul( const Value alpha )
: a( alpha )
{}

double operator() ( double x1 , double x2 ) const // this has to be const?!
{
return x1*x2*a;
}
};

int main()
{
auto functor = hpx::util::unwrap(mul<double>( 0.5 ));
future_type f1 = hpx::make_ready_future( 1.0 );

// compile error even when using full namespace
future_type f2 = hpx::lcos::local::dataflow( functor , f1 , f1 );
future_type f3 = hpx::lcos::local::dataflow( hpx::util::unwrap(mul<double>( 2.0 )) , f1 , f1 );

hpx::wait_all(f1, f2, f3);

return 0;
}

0 comments on commit f6477f1

Please sign in to comment.