Exemplo n.º 1
0
int future_callback(
    bool& data_cb_called
  , bool& error_cb_called
  , hpx::lcos::future<int> f
    )
{
    if (f.has_value()) {
        data_cb_called = true;
        int result = f.get();
        HPX_TEST_EQ(result, 42);
        return result;
    }

    error_cb_called = true;
    HPX_TEST(f.has_exception());

    std::string what_msg;

    try {
        f.get();          // should rethrow
        HPX_TEST(false);
    }
    catch (std::exception const& e) {
        what_msg = e.what();
        HPX_TEST(true);
    }

    HPX_TEST_EQ(what_msg, error_msg);
    return -1;
}
Exemplo n.º 2
0
int p2(hpx::lcos::future<int> f)
{
    HPX_TEST(f.valid());
    int i = f.get();
    hpx::this_thread::sleep_for(boost::chrono::milliseconds(500));
    return 2 * i;
}
Exemplo n.º 3
0
void p3(hpx::lcos::future<int> f)
{
    HPX_TEST(f.valid());
    int i = f.get();
    (void)i;
    hpx::this_thread::sleep_for(boost::posix_time::milliseconds(500));
    return;
}
Exemplo n.º 4
0
 boost::uint64_t operator()(
     hpx::lcos::future<data_type> data
 ) const
 {
     data_type v = data.get();
     return hpx::util::get<0>(v).get() + hpx::util::get<1>(v).get();
 }
Exemplo n.º 5
0
        void stencil_iterator::update(
            hpx::lcos::future<row_range> dst
          , hpx::lcos::future<row_range> src
          , hpx::lcos::future<row_range> top
          , hpx::lcos::future<row_range> bottom
        )
        {
            row_range d = dst.get();

            std::vector<double>::iterator dst_ptr = d.begin();
            row_range s = src.get();
            std::vector<double>::iterator src_ptr = s.begin();
            row_range t = top.get();
            std::vector<double>::iterator top_ptr = t.begin();
            row_range b = bottom.get();
            std::vector<double>::iterator bottom_ptr = b.begin();

            HPX_ASSERT(
                d.end() - d.begin() + 2 == s.end() - s.begin()
            );
            HPX_ASSERT(
                d.end() - d.begin() == t.end() - t.begin()
            );
            HPX_ASSERT(
                d.end() - d.begin() == b.end() - b.begin()
            );

            ++src_ptr;
            while(dst_ptr < d.end())
            {
                HPX_ASSERT(dst_ptr < d.end());
                HPX_ASSERT(src_ptr < s.end());
                HPX_ASSERT(top_ptr < t.end());
                HPX_ASSERT(bottom_ptr < b.end());
                *dst_ptr
                    =(
                        *(src_ptr - 1) + *(src_ptr + 1)
                      + *top_ptr + *bottom_ptr
                    ) * 0.25;
                ++dst_ptr;
                ++src_ptr;
                ++top_ptr;
                ++bottom_ptr;
            }
        }
Exemplo n.º 6
0
 result_type operator()(
     hpx::lcos::future<data_type> data
 ) const
 {
     data_type v = data.move();
     std::cout << HPX_STD_GET(0, v).get() << "\n";
     std::cout << HPX_STD_GET(1, v).get() << "\n";
     std::cout << HPX_STD_GET(2, v).get() << "\n";
 }
Exemplo n.º 7
0
 void operator()(
     hpx::lcos::future<data_type> data
 ) const
 {
     data_type v = data.get();
     std::cout << hpx::util::get<0>(v).get() << "\n";
     std::cout << hpx::util::get<1>(v).get() << "\n";
     std::cout << hpx::util::get<2>(v).get() << "\n";
 }
Exemplo n.º 8
0
        void operator()(hpx::lcos::future<std::vector<double> > f)
        {
            std::vector<double> result = f.get();
            std::vector<std::size_t> const& indicies = data_.get().indicies_;

            if (result.size() != indicies.size()) {
                HPX_THROW_EXCEPTION(hpx::bad_parameter,
                    "interpolator::on_completed_bulk_one",
                    "inconsistent sizes of result and index arrays");
            }

            std::vector<double>& overall_result = overall_result_.get();
            for (std::size_t i = 0; i < indicies.size(); ++i)
                overall_result[indicies[i]] = result[i];
        }