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;
   }
Пример #2
0
 explicit E(int i, int j, const allocator_type& a)
 {
     assert(i == 1);
     assert(j == 2);
     assert(a.id() == 50);
     constructed = true;
 }
Пример #3
0
	void push(T &&new_value) {
		auto ptr = allocator.allocate(1);
		::new (ptr) T(std::move(new_value));

		stored_ptr new_data(ptr);

		push(std::move(new_data));
	}
 static bucket_ptr create_buckets(allocator_type &alloc, size_type num)
 {
    num = index_type::suggested_upper_bucket_count(num);
    bucket_ptr buckets = alloc.allocate(num);
    bucket_ptr buckets_init = buckets;
    for(size_type i = 0; i < num; ++i){
       new(to_raw_pointer(buckets_init++))bucket_type();
    }
    return buckets;
 }
 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;
 }
   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;
   }
Пример #7
0
 static void construct(allocator_type& a, U* p, Args&&... args)
 {a.construct(p, std::forward<Args>(args)...);}
Пример #8
0
      void
      _M_deallocate_node(_Node_* const __P)
      {
	// Deallocate a node of size sizeof(_Node_)!
        return _M_node_allocator.deallocate(__P, 1*sizeof(_Node_));
      }
Пример #9
0
 //-------------------------------------------------------------------
 //! Deallocate a bunch of memory.
 //-------------------------------------------------------------------
 static void
 deallocate(const allocator_type &a, T *ptr, 
            size_type const n = size_type())
 {
   return a->deallocate(ptr);
 }
Пример #10
0
 explicit C(std::allocator_arg_t, const allocator_type& a, int i)
 {
     assert(a.id() == 7);
     assert(i == 8);
     constructed = true;
 }
Пример #11
0
 pointer allocate(size_type n){
     return static_cast<pointer>(A_.allocate(n*sizeof(T)));
 }
Пример #12
0
      _Node_*
      _M_allocate_node()
      {
	// Allocate a new node of size sizeof(_Node_)!
        return (_Node_*) _M_node_allocator.allocate(1*sizeof(_Node_));
      }
Пример #13
0
		inline void destroy() noexcept
		{
			alloc_.destroy(data_);
			has_not_destroy_=false;
		}
Пример #14
0
		void construct(Args &&...args) noexcept(std::is_nothrow_constructible<value_type,Args...>::value)
		{
			alloc_.construct(data_,std::forward<decltype(args)>(args)...);
			has_not_destroy_=true;
		}
Пример #15
0
		CAlloc_obj()
			:data_{alloc_.allocate(1)},has_not_destroy_{false}{}
Пример #16
0
 static void destroy(allocator_type& a, U* p) {a.destroy(p);}
Пример #17
0
 void construct(pointer finish, const_reference &c){
     A_.construct(finish, c);
 }
Пример #18
0
 void deallocate(pointer p, size_type n){
     A_.deallocate(p, n*sizeof(T));
 }
Пример #19
0
 void destroy(pointer start, pointer end){
     while (start != end){
         A_.destroy(start++);
     }
 }
Пример #20
0
 void
 _M_destroy_node(_Node_* __p)
 {
     _M_node_allocator.destroy(__p);
 }
Пример #21
0
		~CAlloc_obj()
		{
			if(has_not_destroy())
				destroy();
			alloc_.deallocate(data_,1);
		}
Пример #22
0
 void
 _M_deallocate_node(_Node_* const __P)
 {
     return _M_node_allocator.deallocate(__P, 1);
 }
Пример #23
0
 _Node_*
 _M_allocate_node()
 {
     return _M_node_allocator.allocate(1);
 }
Пример #24
0
	static inline void deallocate(void * p)
		{ allocator.release((data_type *)p); }
Пример #25
0
	static inline void *allocate()
		{ return allocator.acquire(); }
 static void destroy_buckets
    (allocator_type &alloc, bucket_ptr buckets, size_type num)
 {
    bucket_ptr buckets_destroy = buckets;
    for(size_type i = 0; i < num; ++i){
       to_raw_pointer(buckets_destroy++)->~bucket_type();
    }
    alloc.deallocate(buckets, num);
 }