예제 #1
0
        static lcos::future<Result>
        call(naming::id_type const& id, naming::address && addr, Ts &&... vs)
        {
            bool target_is_managed = false;
            naming::id_type id1;

            if (id.get_management_type() == naming::id_type::managed)
            {
                id1 = naming::id_type(id.get_gid(), naming::id_type::unmanaged);
                target_is_managed = true;
            }

            lcos::packaged_action<Action, Result> p;
            p.apply(std::move(addr), target_is_managed ? id1 : id,
                std::forward<Ts>(vs)...);

            // keep id alive, if needed - this allows to send the destination
            // as an unmanaged id
            future<Result> f = p.get_future();

            if (target_is_managed)
            {
                typedef typename traits::detail::shared_state_ptr_for<
                    future<Result>
                >::type shared_state_ptr;

                shared_state_ptr const& state = traits::detail::get_shared_state(f);
                state->set_on_completed(hpx::detail::keep_id_alive(id));
            }

            return f;
        }
예제 #2
0
 typename boost::enable_if_c<
     util::tuple_size<typename Action::arguments_type>::value == 1
   , lcos::future<
         typename traits::promise_local_result<
             typename hpx::actions::extract_action<Action>::remote_result_type
         >::type>
 >::type
 async_colocated(
     naming::id_type const& gid
   , Arg0 && arg0)
 {
     
     
     agas::request req(agas::primary_ns_resolve_gid, gid.get_gid());
     naming::id_type service_target(
         agas::stubs::primary_namespace::get_service_instance(gid.get_gid())
       , naming::id_type::unmanaged);
     typedef agas::server::primary_namespace::service_action action_type;
     using util::placeholders::_2;
     return async_continue<action_type>(
         service_target, req
       , util::functional::async_continuation(
             util::bind<Action>(
                 util::bind(util::functional::extract_locality(gid), _2)
               , std::forward<Arg0>( arg0 ))
             ));
 }
예제 #3
0
    typename std::enable_if<
        traits::is_continuation<Continuation>::value
      , bool
    >::type
    apply_colocated(Continuation && cont,
        naming::id_type const& gid, Ts&&... vs)
    {
        // shortcut co-location code if target already is a locality
        if (naming::is_locality(gid))
        {
            return apply_c<Action>(std::forward<Continuation>(cont), gid,
                std::forward<Ts>(vs)...);
        }

        // Attach the requested action as a continuation to a resolve_async
        // call on the locality responsible for the target gid.
        agas::request req(agas::primary_ns_resolve_gid, gid.get_gid());
        naming::id_type service_target(
            agas::stubs::primary_namespace::get_service_instance(gid.get_gid()),
            naming::id_type::unmanaged);

        typedef agas::server::primary_namespace::service_action action_type;

        using util::placeholders::_2;
        return apply_continue<action_type>(
            util::functional::apply_continuation(
                util::bind<Action>(
                    util::bind(util::functional::extract_locality(), _2, gid),
                    std::forward<Ts>(vs)...),
                std::forward<Continuation>(cont)),
            service_target, req);
    }
예제 #4
0
    void trigger_lco_event(naming::id_type const& id, naming::address && addr,
        naming::id_type const& cont, bool move_credits)
    {
        typedef lcos::base_lco::set_event_action set_action;
        typedef
            hpx::traits::extract_action<set_action>::local_result_type
            local_result_type;
        typedef
            hpx::traits::extract_action<set_action>::remote_result_type
            remote_result_type;
        if (move_credits &&
            id.get_management_type() != naming::id_type::unmanaged)
        {
            naming::id_type target(id.get_gid(), id_type::managed_move_credit);
            id.make_unmanaged();

            detail::apply_impl<set_action>(
                actions::typed_continuation<
                    local_result_type, remote_result_type>(cont),
                target, std::move(addr), actions::action_priority<set_action>());
        }
        else
        {
            detail::apply_impl<set_action>(
                actions::typed_continuation<
                    local_result_type, remote_result_type>(cont),
                id, std::move(addr), actions::action_priority<set_action>());
        }
    }
예제 #5
0
naming::gid_type component_storage::migrate_to_here(
    std::vector<char> const& data, naming::id_type id,
    naming::address const& current_lva)
{
    naming::gid_type gid(naming::detail::get_stripped_gid(id.get_gid()));
    data_[gid] = data;

    // rebind the object to this storage locality
    naming::address addr(current_lva);
    addr.address_ = 0;       // invalidate lva
    if (!agas::bind(launch::sync, gid, addr, this->gid_))
    {
        std::ostringstream strm;
        strm << "failed to rebind id " << id
             << "to storage locality: " << gid_;

        HPX_THROW_EXCEPTION(duplicate_component_address,
                            "component_storage::migrate_to_here",
                            strm.str());
        return naming::invalid_gid;
    }

    id.make_unmanaged();            // we can now release the object
    return naming::invalid_gid;
}
예제 #6
0
    lcos::future<
        typename traits::promise_local_result<
            typename hpx::traits::extract_action<Action>::remote_result_type
        >::type>
    async_colocated(naming::id_type const& gid, Ts&&... vs)
    {
        // Attach the requested action as a continuation to a resolve_async
        // call on the locality responsible for the target gid.
        naming::id_type service_target(
            agas::primary_namespace::get_service_instance(gid.get_gid())
          , naming::id_type::unmanaged);

        typedef
            typename hpx::traits::extract_action<Action>::remote_result_type
            remote_result_type;
        typedef agas::server::primary_namespace::colocate_action action_type;

        using util::placeholders::_2;
        return detail::async_continue_r<action_type, remote_result_type>(
            util::functional::async_continuation(
                util::bind<Action>(
                    util::bind(util::functional::extract_locality(), _2, gid)
                  , std::forward<Ts>(vs)...)
                ), service_target, gid.get_gid());
    }
예제 #7
0
    bool apply_colocated_cb(Continuation && cont,
        naming::id_type const& gid, Callback&& cb, Ts&&... vs)
    {
        // shortcut co-location code if target already is a locality
        if (naming::is_locality(gid))
        {
            return apply_p_cb<Action>(std::forward<Continuation>(cont), gid,
                actions::action_priority<Action>(),
                std::forward<Callback>(cb), std::forward<Ts>(vs)...);
        }

        // Attach the requested action as a continuation to a resolve_async
        // call on the locality responsible for the target gid.
        naming::id_type service_target(
            agas::primary_namespace::get_service_instance(gid.get_gid()),
            naming::id_type::unmanaged);

        typedef agas::server::primary_namespace::colocate_action action_type;

        using util::placeholders::_2;
        return apply_continue_cb<action_type>(
            util::functional::apply_continuation(
                util::bind<Action>(
                    util::bind(util::functional::extract_locality(), _2, gid)
                  , std::forward<Ts>(vs)...)
              , std::forward<Continuation>(cont)),
            service_target, std::forward<Callback>(cb), gid.get_gid());
    }
예제 #8
0
    void set_lco_error(naming::id_type const& id, boost::exception_ptr const& e)
    {
        naming::id_type target(id.get_gid(), id_type::managed_move_credit);
        id.make_unmanaged();

        lcos::base_lco::set_exception_action set;
        apply(set, target, e);
    }
예제 #9
0
    void trigger_lco_event(naming::id_type const& id, naming::id_type const& cont)
    {
        naming::id_type target(id.get_gid(), id_type::managed_move_credit);
        id.make_unmanaged();

        lcos::base_lco::set_event_action set;
        apply_c(set, cont, target);
    }
예제 #10
0
    void set_lco_error(naming::id_type const& id, //-V659
        boost::exception_ptr && e, naming::id_type const& cont)
    {
        naming::id_type target(id.get_gid(), id_type::managed_move_credit);
        id.make_unmanaged();

        lcos::base_lco::set_exception_action set;
        apply_c(set, cont, target, std::move(e));
    }
예제 #11
0
파일: interface.hpp 프로젝트: 41i/hpx
inline bool is_local_address_cached(
    naming::id_type const& gid
  , error_code& ec = throws
    )
{
    return is_local_address_cached(gid.get_gid(), ec);
}
예제 #12
0
    void set_lco_error(naming::id_type const& id, naming::address && addr,
        std::exception_ptr const& e, bool move_credits)
    {
        typedef lcos::base_lco::set_exception_action set_action;
        if (move_credits &&
            id.get_management_type() != naming::id_type::unmanaged)
        {
            naming::id_type target(id.get_gid(), id_type::managed_move_credit);
            id.make_unmanaged();

            detail::apply_impl<set_action>(
                target, std::move(addr), actions::action_priority<set_action>(), e);
        }
        else
        {
            detail::apply_impl<set_action>(
                id, std::move(addr), actions::action_priority<set_action>(), e);
        }
    }
예제 #13
0
    bool apply_colocated(naming::id_type const& gid, Ts&&... vs)
    {
        // Attach the requested action as a continuation to a resolve_async
        // call on the locality responsible for the target gid.
        agas::request req(agas::primary_ns_resolve_gid, gid.get_gid());
        naming::id_type service_target(
            agas::stubs::primary_namespace::get_service_instance(gid.get_gid()),
            naming::id_type::unmanaged);

        typedef agas::server::primary_namespace::service_action action_type;

        using util::placeholders::_2;
        return apply_continue<action_type>(
            util::functional::apply_continuation(
                util::bind<Action>(
                    util::bind(util::functional::extract_locality(), _2, gid),
                    std::forward<Ts>(vs)...)),
            service_target, req);
    }
예제 #14
0
파일: apply.hpp 프로젝트: NOMORECOFFEE/hpx
        inline bool
        apply_r_p(naming::address& addr, naming::id_type const& gid,
            threads::thread_priority priority)
        {
            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));

            // Send the parcel through the parcel handler
            hpx::applier::get_applier().get_parcel_handler().put_parcel(p);
            return false;     // destination is remote
        }
예제 #15
0
 static bool is_service_instance(naming::id_type const& id)
 {
     return is_service_instance(id.get_gid());
 }
예제 #16
0
 static naming::gid_type get_service_instance(naming::id_type const& dest)
 {
     return get_service_instance(dest.get_gid());
 }
예제 #17
0
파일: interface.hpp 프로젝트: 41i/hpx
inline bool is_local_lva_encoded_address(
    naming::id_type const& gid
    )
{
    return is_local_lva_encoded_address(gid.get_gid());
}