void apply(BOOST_SCOPED_ENUM(launch) /*policy*/, naming::address& addr,
        naming::id_type const& gid, HPX_ENUM_FWD_ARGS(N, Arg, arg))
    {
        util::block_profiler_wrapper<profiler_tag> bp(apply_logger_);

        if (addr.locality_ == hpx::get_locality()) {
            // local, direct execution
            HPX_ASSERT(components::types_are_compatible(addr.type_,
                components::get_component_type<
                    typename action_type::component_type>()));

            (*this->impl_)->set_data(
                std::move(action_type::execute_function(addr.address_,
                    util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, Arg, arg))))
            );
        }
        else {
            // remote execution
            hpx::applier::detail::apply_c_cb<action_type>(
                addr, this->get_gid(), gid,
                HPX_STD_BIND(&packaged_action::parcel_write_handler, this->impl_,
                    HPX_STD_PLACEHOLDERS::_1),
                HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
        }
    }
    void apply(BOOST_SCOPED_ENUM(launch) /*policy*/, naming::id_type const& gid,
        HPX_ENUM_FWD_ARGS(N, Arg, arg))
    {
        util::block_profiler_wrapper<profiler_tag> bp(apply_logger_);

        naming::address addr;
        if (agas::is_local_address_cached(gid, addr)) {
            // local, direct execution
            HPX_ASSERT(traits::component_type_is_compatible<
                typename Action::component_type>::call(addr));

            (*this->impl_)->set_data(
                std::move(action_type::execute_function(addr.address_,
                    util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, Arg, arg))))
            );
        }
        else {
            // remote execution
            hpx::applier::detail::apply_c_cb<action_type>(
                std::move(addr), this->get_gid(), gid,
                util::bind(&packaged_action::parcel_write_handler,
                    this->impl_, util::placeholders::_1, util::placeholders::_2),
                HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
        }
    }
 void apply(naming::id_type const& gid,
     HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     util::block_profiler_wrapper<deferred_packaged_task_tag> bp(apply_logger_);
     hpx::apply_c<Action>(
         this->get_gid(), gid, HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 4
0
        inline bool
        apply_r_p(std::vector<naming::address>& addrs,
            std::vector<naming::gid_type> const& gids,
            threads::thread_priority priority, HPX_ENUM_FWD_ARGS(N, Arg, arg))
        {
            typedef typename hpx::actions::extract_action<Action>::type action_type;

            // sort destinations
            std::map<naming::locality, destinations> dests;

            std::size_t count = gids.size();
            for (std::size_t i = 0; i < count; ++i) {
                complement_addr<action_type>(addrs[i]);

                destinations& dest = dests[addrs[i].locality_];
                dest.gids_.push_back(gids[i]);
                dest.addrs_.push_back(addrs[i]);
            }

            // send one parcel to each of the destination localities
            parcelset::parcelhandler& ph =
                hpx::applier::get_applier().get_parcel_handler();
            actions::action_type act(
                new hpx::actions::transfer_action<action_type>(priority,
                    util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, Arg, arg))));

            std::for_each(dests.begin(), dests.end(), send_parcel(ph, act));

            return false;     // destinations are remote
        }
Ejemplo n.º 5
0
 inline bool
 apply_l (naming::address const& addr, HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     return apply_l_p<Action>(addr,
         actions::action_priority<Action>(),
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 6
0
 void apply_p(naming::id_type const& gid,
     threads::thread_priority priority, HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     util::block_profiler_wrapper<profiler_tag> bp(apply_logger_);
     hpx::apply_c_p<action_type>(this->get_gid(), gid, priority,
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 7
0
 inline bool
 apply_r_cb(naming::address&& addr, naming::id_type const& gid,
     Callback && cb, HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     return apply_r_p_cb<Action>(std::move(addr), gid,
         actions::action_priority<Action>(), std::forward<Callback>(cb),
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 8
0
 inline bool
 apply_r (naming::address& addr, naming::id_type const& gid,
     HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     return apply_r_p<Action>(addr, gid,
         actions::action_priority<Action>(),
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 9
0
 BOOST_FORCEINLINE
 typename result<bound(BOOST_PP_ENUM_PARAMS(N, U))>::type
 operator()(HPX_ENUM_FWD_ARGS(N, U, u))
 {
     return
         detail::bind_invoke(
             _f, _bound_args
           , util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, U, u))
         );
 }
 packaged_action(naming::id_type const& gid,
         HPX_ENUM_FWD_ARGS(N, Arg, arg))
   : apply_logger_("packaged_action_direct::apply")
 {
     LLCO_(info) << "packaged_action::packaged_action("
                 << hpx::actions::detail::get_action_name<action_type>()
                 << ", "
                 << gid
                 << ") args(" << (N + 1) << ")";
     apply(launch::all, gid, HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 11
0
 inline bool
 apply_r_p_cb(naming::address&& addr, naming::id_type const& id,
     threads::thread_priority priority, Callback && cb,
     HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     // If remote, create a new parcel to be sent to the destination
     // Create a new parcel with the gid, action, and arguments
     lcos::local::detail::invoke_when_ready(
         detail::put_parcel<Action>(id, std::move(addr), priority,
             actions::continuation_type(), std::forward<Callback>(cb)),
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
     return false;     // destinations are remote
 }
Ejemplo n.º 12
0
 packaged_action(naming::gid_type const& gid,
         threads::thread_priority priority,
         HPX_ENUM_FWD_ARGS(N, Arg, arg))
   : apply_logger_("packaged_action::apply")
 {
     LLCO_(info) << "packaged_action::packaged_action("
                 << hpx::actions::detail::get_action_name<action_type>()
                 << ", "
                 << gid
                 << ") args(" << (N + 1) << ")";
     apply_p(naming::id_type(gid, naming::id_type::unmanaged),
         priority, HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 13
0
 future<
     typename traits::promise_local_result<
         typename hpx::actions::extract_action<Action>::result_type
     >::type,
     typename hpx::actions::extract_action<Action>::result_type
 >
 async (naming::id_type const& gid,
     HPX_ENUM_FWD_ARGS(N, Arg, arg))
 {
     typedef hpx::actions::extract_action<Action>::type action_type;
     return packaged_action_route<action_type>(gid,
         HPX_ENUM_FORWARD_ARGS(N, Arg, arg)).get_future();
 }
Ejemplo n.º 14
0
 packaged_action(naming::id_type const& gid,
         completed_callback_type const& data_sink,
         HPX_ENUM_FWD_ARGS(N, Arg, arg))
   : base_type(data_sink),
     apply_logger_("packaged_action::apply")
 {
     LLCO_(info) << "packaged_action::packaged_action("
                 << hpx::actions::detail::get_action_name<action_type>()
                 << ", "
                 << gid
                 << ") args(" << (N + 1) << ")";
     apply(gid, HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
 }
Ejemplo n.º 15
0
        inline bool
        apply_l_p(naming::id_type const& target, naming::address const& addr,
            threads::thread_priority priority, HPX_ENUM_FWD_ARGS(N, Arg, arg))
        {
            typedef typename hpx::actions::extract_action<Action>::type action_type;

            HPX_ASSERT(components::types_are_compatible(addr.type_,
                components::get_component_type<
                    typename action_type::component_type>()));

            apply_helper<action_type>::call(target, addr.address_, priority,
                util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, Arg, arg)));
            return true;     // no parcel has been sent (dest is local)
        }
Ejemplo n.º 16
0
        inline bool
        apply_r_p(naming::address& addr, naming::id_type const& id,
            threads::thread_priority priority, HPX_ENUM_FWD_ARGS(N, Arg, arg))
        {
            typedef typename hpx::actions::extract_action<Action>::type action_type;

            // If remote, create a new parcel to be sent to the destination
            // Create a new parcel with the gid, action, and arguments
            parcelset::parcel p(id, complement_addr<action_type>(addr),
                new hpx::actions::transfer_action<action_type>(priority,
                    util::forward_as_tuple(HPX_ENUM_FORWARD_ARGS(N, Arg, arg))));

            // Send the parcel through the parcel handler
            hpx::applier::get_applier().get_parcel_handler().put_parcel(p);
            return false;     // destinations are remote
        }
Ejemplo n.º 17
0
            BOOST_FORCEINLINE result_type operator()(
                naming::address::address_type lva,
                HPX_ENUM_FWD_ARGS(N, Arg, arg)) const
            {
                try {
                    LTM_(debug) << "Executing component action("
                                << detail::get_action_name<Derived>()
                                << ") lva(" << reinterpret_cast<void const*>
                                    (get_lva<Component>::call(lva)) << ")";

                    (get_lva<Component>::call(lva)->*F)(
                        HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
                }
                catch (hpx::thread_interrupted const&) {
                    /* swallow this exception */
                }
                catch (hpx::exception const& e) {
                    LTM_(error)
                        << "Unhandled exception while executing component action("
                        << detail::get_action_name<Derived>()
                        << ") lva(" << reinterpret_cast<void const*>
                            (get_lva<Component>::call(lva)) << "): " << e.what();

                    // report this error to the console in any case
                    hpx::report_error(boost::current_exception());
                }
                catch (...) {
                    LTM_(error)
                        << "Unhandled exception while executing component action("
                        << detail::get_action_name<Derived>()
                        << ") lva(" << reinterpret_cast<void const*>
                            (get_lva<Component>::call(lva)) << ")";

                    // report this error to the console in any case
                    hpx::report_error(boost::current_exception());
                }

                // Verify that there are no more registered locks for this
                // OS-thread. This will throw if there are still any locks
                // held.
                util::force_error_on_lock();
                return threads::terminated;
            }
Ejemplo n.º 18
0
future<
typename traits::promise_local_result<
typename hpx::actions::extract_action<Action>::result_type
>::type,
typename hpx::actions::extract_action<Action>::result_type
>
async_callback (
    HPX_STD_FUNCTION<void(future<typename traits::promise_local_result<
                          typename hpx::actions::extract_action<Action>::result_type
                          >::type>)> const& data_sink, naming::id_type const& gid,
    HPX_ENUM_FWD_ARGS(N, Arg, arg))
{
    typedef hpx::actions::extract_action<Action>::type action_type;
    typedef typename traits::promise_local_result<
    typename action_type::result_type
    >::type result_type;
    typedef packaged_action_route<action_type, result_type> future_type;

    return future_type(gid, data_sink,
                       HPX_ENUM_FORWARD_ARGS(N, Arg, arg)).get_future();
}
Ejemplo n.º 19
0
Archivo: when_all.hpp Proyecto: 41i/hpx
 lcos::unique_future<HPX_STD_TUPLE<BOOST_PP_ENUM(N, HPX_WHEN_N_DECAY_FUTURE, _)> >
 when_all(HPX_ENUM_FWD_ARGS(N, T, f), error_code& ec = throws)
 {
     return lcos::when_n(N, HPX_ENUM_FORWARD_ARGS(N, T, f), ec);
 }
Ejemplo n.º 20
0
    namespace applier { namespace detail
    {
        template <typename Action, typename Callback,
            BOOST_PP_ENUM_PARAMS(N, typename Arg)>
        inline bool
        apply_r_p_cb(naming::address& addr, naming::id_type const& gid,
            threads::thread_priority priority, BOOST_FWD_REF(Callback) cb,
            HPX_ENUM_FWD_ARGS(N, Arg, arg))
        {
            typedef typename hpx::actions::extract_action<Action>::type action_type;

            // If remote, create a new parcel to be sent to the destination
            // Create a new parcel with the gid, action, and arguments
            parcelset::parcel p (gid.get_gid(), complement_addr<action_type>(addr),
                new hpx::actions::transfer_action<action_type>(
                    priority, HPX_ENUM_FORWARD_ARGS(N, Arg, arg)));

            // Send the parcel through the parcel handler
            hpx::applier::get_applier().get_parcel_handler()
                .put_parcel(p, boost::forward<Callback>(cb));
            return false;     // destinations are remote
        }

        template <typename Action, typename Callback,
            BOOST_PP_ENUM_PARAMS(N, typename Arg)>
        inline bool
        apply_r_cb(naming::address& addr, naming::id_type const& gid,
            BOOST_FWD_REF(Callback) cb, HPX_ENUM_FWD_ARGS(N, Arg, arg))
        {
            return apply_r_p_cb<Action>(addr, gid,
                actions::action_priority<Action>(), boost::forward<Callback>(cb),
Ejemplo n.º 21
0
//  Preprocessor vertical repetition code
///////////////////////////////////////////////////////////////////////////////
#else // defined(BOOST_PP_IS_ITERATING)

#define N BOOST_PP_ITERATION()

    template <BOOST_PP_ENUM_PARAMS(N, typename Arg)>
    void apply(BOOST_SCOPED_ENUM(launch) policy, naming::id_type const& gid,
        HPX_ENUM_FWD_ARGS(N, Arg, arg))
    {
        util::block_profiler_wrapper<profiler_tag> bp(apply_logger_);

        hpx::apply_c_cb<action_type>(this->get_gid(), gid,
            HPX_STD_BIND(&packaged_action::parcel_write_handler, this->impl_,
                HPX_STD_PLACEHOLDERS::_1),
            HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
    }

    template <BOOST_PP_ENUM_PARAMS(N, typename Arg)>
    void apply(BOOST_SCOPED_ENUM(launch) policy, naming::address& addr,
        naming::id_type const& gid, HPX_ENUM_FWD_ARGS(N, Arg, arg))
    {
        util::block_profiler_wrapper<profiler_tag> bp(apply_logger_);

        hpx::apply_c_cb<action_type>(this->get_gid(), addr, gid,
            HPX_STD_BIND(&packaged_action::parcel_write_handler, this->impl_,
                HPX_STD_PLACEHOLDERS::_1),
            HPX_ENUM_FORWARD_ARGS(N, Arg, arg));
    }

    template <BOOST_PP_ENUM_PARAMS(N, typename Arg)>