当前位置: 首页>>代码示例>>C++>>正文


C++ parcel::addrs方法代码示例

本文整理汇总了C++中parcel::addrs方法的典型用法代码示例。如果您正苦于以下问题:C++ parcel::addrs方法的具体用法?C++ parcel::addrs怎么用?C++ parcel::addrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parcel的用法示例。


在下文中一共展示了parcel::addrs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: put_parcel

void parcelhandler::put_parcel(parcel p, write_handler_type f)
{
    HPX_ASSERT(resolver_);

    naming::id_type const* ids = p.destinations();
    naming::address* addrs = p.addrs();

    // During bootstrap this is handled separately (see
    // addressing_service::resolve_locality.
    if (0 == hpx::threads::get_self_ptr() && !hpx::is_starting())
    {
        HPX_ASSERT(resolver_);
        naming::gid_type locality =
            naming::get_locality_from_gid(ids[0].get_gid());
        if (!resolver_->has_resolved_locality(locality))
        {
            // reschedule request as an HPX thread to avoid hangs
            void (parcelhandler::*put_parcel_ptr) (
                parcel p, write_handler_type f
            ) = &parcelhandler::put_parcel;

            threads::register_thread_nullary(
                util::bind(
                    util::one_shot(put_parcel_ptr), this,
                    std::move(p), std::move(f)),
                "parcelhandler::put_parcel", threads::pending, true,
                threads::thread_priority_boost);
            return;
        }
    }

    // properly initialize parcel
    init_parcel(p);

    bool resolved_locally = true;

#if !defined(HPX_SUPPORT_MULTIPLE_PARCEL_DESTINATIONS)
    if (!addrs[0])
    {
        resolved_locally = resolver_->resolve_local(ids[0], addrs[0]);
    }
#else
    std::size_t size = p.size();

    if (0 == size) {
        HPX_THROW_EXCEPTION(network_error, "parcelhandler::put_parcel",
                            "no destination address given");
        return;
    }

    if (1 == size) {
        if (!addrs[0])
            resolved_locally = resolver_->resolve_local(ids[0], addrs[0]);
    }
    else {
        boost::dynamic_bitset<> locals;
        resolved_locally = resolver_->resolve_local(ids, addrs, size, locals);
    }
#endif

    if (!p.parcel_id())
        p.parcel_id() = parcel::generate_unique_id();

    using util::placeholders::_1;
    using util::placeholders::_2;
    write_handler_type wrapped_f =
        util::bind(&detail::parcel_sent_handler, std::move(f), _1, _2);

    // If we were able to resolve the address(es) locally we send the
    // parcel directly to the destination.
    if (resolved_locally)
    {
        // dispatch to the message handler which is associated with the
        // encapsulated action
        typedef std::pair<boost::shared_ptr<parcelport>, locality> destination_pair;
        destination_pair dest = find_appropriate_destination(addrs[0].locality_);

        if (load_message_handlers_)
        {
            policies::message_handler* mh =
                p.get_message_handler(this, dest.second);

            if (mh) {
                mh->put_parcel(dest.second, std::move(p), std::move(wrapped_f));
                return;
            }
        }

        dest.first->put_parcel(dest.second, std::move(p), std::move(wrapped_f));
        return;
    }

    // At least one of the addresses is locally unknown, route the parcel
    // to the AGAS managing the destination.
    ++count_routed_;

    resolver_->route(std::move(p), std::move(wrapped_f));
}
开发者ID:parsa,项目名称:hpx,代码行数:98,代码来源:parcelhandler.cpp


注:本文中的parcel::addrs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。