Example #1
0
File: wait_n.hpp Project: eile/hpx
    void wait_n(std::size_t n, HPX_ENUM_FWD_ARGS(N, T, f),
        error_code& ec = throws)
    {
        typedef HPX_STD_TUPLE<
            BOOST_PP_ENUM(N, HPX_WAIT_N_SHARED_STATE_FOR_FUTURE, _)>
            result_type;

        result_type lazy_values_(
            BOOST_PP_ENUM(N, HPX_WAIT_N_GET_SHARED_STATE, _));

        if (n == 0)
        {
            return;
        }

        if (n > N)
        {
            HPX_THROWS_IF(ec, hpx::bad_parameter,
                "hpx::lcos::wait_n",
                "number of results to wait for is out of bounds");
            return;
        }

        boost::shared_ptr<detail::wait_n<result_type> > f =
            boost::make_shared<detail::wait_n<result_type> >(
                std::move(lazy_values_), n);

        return (*f.get())();
    }
Example #2
0
 void wait_some(std::size_t n, T0 && f0 , T1 && f1 , T2 && f2,
     error_code& ec = throws)
 {
     typedef HPX_STD_TUPLE<
         typename lcos::detail::shared_state_ptr_for<T0>::type , typename lcos::detail::shared_state_ptr_for<T1>::type , typename lcos::detail::shared_state_ptr_for<T2>::type>
         result_type;
     result_type lazy_values_(
         lcos::detail::get_shared_state(f0) , lcos::detail::get_shared_state(f1) , lcos::detail::get_shared_state(f2));
     if (n == 0)
     {
         return;
     }
     if (n > 3)
     {
         HPX_THROWS_IF(ec, hpx::bad_parameter,
             "hpx::lcos::wait_some",
             "number of results to wait for is out of bounds");
         return;
     }
     boost::shared_ptr<detail::wait_some<result_type> > f =
         boost::make_shared<detail::wait_some<result_type> >(
             std::move(lazy_values_), n);
     return (*f.get())();
 }