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


C++ allocator_type::allocation_command方法代码示例

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


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

示例1:

   static size_type shrink_buckets
      ( bucket_ptr buckets, size_type old_size
      , allocator_type &alloc, size_type new_size)
   {
      if(old_size <= new_size )
         return old_size;
      size_type received_size;
      if(!alloc.allocation_command
         (boost::interprocess::try_shrink_in_place | boost::interprocess::nothrow_allocation, old_size, new_size, received_size, buckets).first){
         return old_size;
      }

      for( bucket_type *p = ipcdetail::to_raw_pointer(buckets) + received_size
         , *pend = ipcdetail::to_raw_pointer(buckets) + old_size
         ; p != pend
         ; ++p){
         p->~bucket_type();
      }

      bucket_ptr shunk_p = alloc.allocation_command
         (boost::interprocess::shrink_in_place | boost::interprocess::nothrow_allocation, received_size, received_size, received_size, buckets).first;
      BOOST_ASSERT(buckets == shunk_p); (void)shunk_p;

      bucket_ptr buckets_init = buckets + received_size;
      for(size_type i = 0; i < (old_size - received_size); ++i){
         to_raw_pointer(buckets_init++)->~bucket_type();
      }
      return received_size;
   }
开发者ID:danieljames,项目名称:interprocess,代码行数:29,代码来源:iunordered_set_index.hpp

示例2: reuse

 static bucket_ptr expand_or_create_buckets
    ( bucket_ptr old_buckets, const size_type old_num
    , allocator_type &alloc,  const size_type new_num)
 {
    size_type received_size = new_num;
    bucket_ptr reuse(old_buckets);
    bucket_ptr ret = alloc.allocation_command
          (boost::interprocess::expand_fwd | boost::interprocess::allocate_new, new_num, received_size, reuse);
    if(ret == old_buckets){
       bucket_ptr buckets_init = old_buckets + old_num;
       for(size_type i = 0; i < (new_num - old_num); ++i){
          ::new(to_raw_pointer(buckets_init++), boost_container_new_t())bucket_type();
       }
    }
    else{
       bucket_ptr buckets_init = ret;
       for(size_type i = 0; i < new_num; ++i){
          ::new(to_raw_pointer(buckets_init++), boost_container_new_t())bucket_type();
       }
    }
    return ret;
 }
开发者ID:alanwoolley,项目名称:innoextract-android,代码行数:22,代码来源:iunordered_set_index.hpp

示例3: new

   static bucket_ptr expand_or_create_buckets
      ( bucket_ptr old_buckets, const size_type old_num
      , allocator_type &alloc,  const size_type new_num)
   {
      size_type received_size;
      std::pair<bucket_ptr, bool> ret =
         alloc.allocation_command
            (boost::interprocess::expand_fwd | boost::interprocess::allocate_new, new_num, new_num, received_size, old_buckets);
      if(ret.first == old_buckets){
         bucket_ptr buckets_init = old_buckets + old_num;
         for(size_type i = 0; i < (new_num - old_num); ++i){
            new(to_raw_pointer(buckets_init++))bucket_type();
         }
      }
      else{
         bucket_ptr buckets_init = ret.first;
         for(size_type i = 0; i < new_num; ++i){
            new(to_raw_pointer(buckets_init++))bucket_type();
         }
      }

      return ret.first;
   }
开发者ID:danieljames,项目名称:interprocess,代码行数:23,代码来源:iunordered_set_index.hpp


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