本文整理汇总了C++中hpx::future类的典型用法代码示例。如果您正苦于以下问题:C++ future类的具体用法?C++ future怎么用?C++ future使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了future类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gather_data
hpx::future<std::vector<T> >
gather_data(hpx::future<hpx::id_type> id, std::size_t site,
hpx::future<T> result)
{
typedef typename gather_server<T>::get_result_action action_type;
return async(action_type(), id.get(), site, result.get());
}
示例2: set_data
hpx::future<void>
set_data(hpx::future<hpx::id_type> id, std::size_t which,
hpx::future<T> result)
{
typedef typename gather_server<T>::set_result_action action_type;
return async(action_type(), id.get(), which, result.get());
}
示例3: then_test_void
void then_test_void(hpx::future<void> f, int passed_through)
{
HPX_ASSERT(f.is_ready()); // make sure, future is ready
f.get(); // propagate exceptions
HPX_TEST_EQ(passed_through, 42);
}
示例4: register_with_basename
/// Register the id wrapped in the given future using the given base name.
///
/// The function registers the object the given future refers to using the
/// provided base name.
///
/// \param base_name [in] The base name for which to retrieve the
/// registered ids.
/// \param f [in] The future which should be registered using
/// the given base name.
/// \param sequence_nr [in, optional] The sequential number to use for the
/// registration of the id. This number has to be
/// unique system wide for each registration using the
/// same base name. The default is the current locality
/// identifier. Also, the sequence numbers have to be
/// consecutive starting from zero.
///
/// \returns A future representing the result of the registration operation
/// itself.
///
/// \note The operation will fail if the given sequence number is not
/// unique.
///
inline hpx::future<bool> register_with_basename(std::string const& base_name,
hpx::future<hpx::id_type> f, std::size_t sequence_nr = ~0U)
{
return f.then(
[=](hpx::future<hpx::id_type> && f) mutable
{
return register_with_basename(base_name, f.get(), sequence_nr);
});
}
示例5: operator
boost::uint64_t operator()(
hpx::future<data_type> data
) const
{
data_type v = data.get();
return HPX_STD_GET(0, v).get() + HPX_STD_GET(1, v).get();
}
示例6: operator
boost::uint64_t operator()(
hpx::future<data_type> data
) const
{
data_type v = data.get();
return hpx::util::get<0>(v).get() + hpx::util::get<1>(v).get();
}
示例7: cont1
// this continuation function will be executed by an HPX thread
int cont1(hpx::future<int> f)
{
hpx::cout << "cont1 thread id: " << hpx::this_thread::get_id() << hpx::endl;
hpx::cout << "Status code (HPX thread): " << f.get() << hpx::endl;
hpx::cout << hpx::flush;
return 1;
}
示例8: register_name
hpx::id_type register_name(hpx::future<hpx::id_type> id,
char const* basename, std::size_t site)
{
hpx::id_type target = id.get();
hpx::register_with_basename(basename, target, site);
return target;
}
示例9: null_callback
void null_callback(
std::vector<double>& dd
, boost::uint64_t j
, hpx::future<double> f
)
{
dd[j] = f.get();
}
示例10: calc_cell
boost::int64_t calc_cell(
boost::uint32_t i
, boost::uint32_t j
, char ai
, char bj
, hpx::future<boost::int64_t> const& left // H(i, j-1)
, hpx::future<boost::int64_t> const& diagonal // H(i-1, j-1)
, hpx::future<boost::int64_t> const& up // H(i-1, j)
)
{
boost::int64_t match_mismatch = 0;
if (ai == bj)
{
match_mismatch = diagonal.get() + match;
}
else
{
match_mismatch = diagonal.get() + mismatch;
}
boost::int64_t deletion = up.get() + gap;
boost::int64_t insertion = left.get() + gap;
boost::int64_t ij_value
= maximum(boost::int64_t(0), match_mismatch, deletion, insertion);
winner H_best_old = H_best.load();
while (true)
{
winner H_best_new(ij_value, i, j);
if (H_best_new.value > H_best_old.value)
{
if (H_best.compare_exchange_weak(H_best_old, H_best_new))
break;
}
else
break;
}
return ij_value;
}
示例11: device_uint_to_string
static std::string
device_uint_to_string(hpx::future<std::vector<char>> data_future)
{
std::vector<char> data_raw = data_future.get();
cl_uint res = *((cl_uint*)data_raw.data());
std::stringstream ss;
ss << res;
return ss.str();
}
示例12: device_type_to_string
static std::string
device_type_to_string(hpx::future<std::vector<char>> type_future)
{
std::vector<char> type_raw = type_future.get();
cl_device_type type = *((cl_device_type*) type_raw.data());
std::vector<std::string> typelist;
if(type & CL_DEVICE_TYPE_CPU)
typelist.push_back("cpu");
if(type & CL_DEVICE_TYPE_GPU)
typelist.push_back("gpu");
if(type & CL_DEVICE_TYPE_ACCELERATOR)
typelist.push_back("accelerator");
if(type & CL_DEVICE_TYPE_DEFAULT)
typelist.push_back("default");
#ifdef CL_VERSION_1_2
if(type & CL_DEVICE_TYPE_CUSTOM)
typelist.push_back("custom");
#endif
std::string result = "";
for(size_t i = 0 ; i < typelist.size(); i++)
{
if(i > 0)
result += ", ";
result += typelist[i];
}
return result;
}
示例13: add
boost::uint64_t add(
hpx::future<boost::uint64_t> f1,
hpx::future<boost::uint64_t> f2)
{
return f1.get() + f2.get();
}
示例14: cont2
// this continuation function will be executed by the UI (main) thread, which is
// not an HPX thread
int cont2(hpx::future<int> f)
{
std::cout << "Status code (main thread): " << f.get() << std::endl;
return 1;
}
示例15: get_ptr_postproc
std::shared_ptr<Component>
get_ptr_postproc(hpx::future<naming::address> f,
naming::id_type const& id)
{
return get_ptr_postproc_helper<Component, Deleter>(f.get(), id);
}