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


C++ request::get_suggested_prefix方法代码示例

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


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

示例1: allocate

response locality_namespace::allocate(
    request const& req
  , error_code& ec
    )
{ // {{{ allocate implementation
    using hpx::util::get;

    // parameters
    parcelset::endpoints_type endpoints = req.get_endpoints();
    boost::uint64_t const count = req.get_count();
    boost::uint32_t const num_threads = req.get_num_threads();
    naming::gid_type const suggested_prefix = req.get_suggested_prefix();

    std::unique_lock<mutex_type> l(mutex_);

#if defined(HPX_DEBUG)
    for (partition_table_type::value_type const& partition : partitions_)
    {
        HPX_ASSERT(get<0>(partition.second) != endpoints);
    }
#endif
    // Check for address space exhaustion.
    if (HPX_UNLIKELY(0xFFFFFFFE < partitions_.size())) //-V104
    {
        l.unlock();

        HPX_THROWS_IF(ec, internal_server_error
          , "locality_namespace::allocate"
          , "primary namespace has been exhausted");
        return response();
    }

    // Compute the locality's prefix.
    boost::uint32_t prefix = naming::invalid_locality_id;

    // check if the suggested prefix can be used instead of the next
    // free one
    boost::uint32_t suggested_locality_id =
        naming::get_locality_id_from_gid(suggested_prefix);

    partition_table_type::iterator it = partitions_.end();
    if (suggested_locality_id != naming::invalid_locality_id)
    {
        it = partitions_.find(suggested_locality_id);

        if(it == partitions_.end())
        {
            prefix = suggested_locality_id;
        }
        else
        {
            do {
                prefix = prefix_counter_++;
                it = partitions_.find(prefix);
            } while (it != partitions_.end());
        }
    }
    else
    {
        do {
            prefix = prefix_counter_++;
            it = partitions_.find(prefix);
        } while (it != partitions_.end());
    }

    // We need to create an entry in the partition table for this
    // locality.
    if(HPX_UNLIKELY(!util::insert_checked(partitions_.insert(
        std::make_pair(prefix, partition_type(endpoints, num_threads))), it)))
    {
        l.unlock();

        HPX_THROWS_IF(ec, lock_error
          , "locality_namespace::allocate"
          , boost::str(boost::format(
                "partition table insertion failed due to a locking "
                "error or memory corruption, endpoint(%1%), "
                "prefix(%2%)") % endpoints % prefix));
        return response();
    }


    // Now that we've inserted the locality into the partition table
    // successfully, we need to put the locality's GID into the GVA
    // table so that parcels can be sent to the memory of a locality.
    if (primary_)
    {
        naming::gid_type id(naming::get_gid_from_locality_id(prefix));
        gva const g(id, components::component_runtime_support, count);

        request req(primary_ns_bind_gid, id, g, id);
        response resp = primary_->service(req, ec);
        if (ec) return resp;
    }

    LAGAS_(info) << (boost::format(
        "locality_namespace::allocate, ep(%1%), count(%2%), "
        "prefix(%3%)")
        % endpoints % count % prefix);

//.........这里部分代码省略.........
开发者ID:AALEKH,项目名称:hpx,代码行数:101,代码来源:locality_namespace_server.cpp


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