Пример #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;
}