< prev index next >

src/hotspot/share/gc/shared/ptrQueue.cpp

Print this page




  77 
  78 BufferNode* BufferNode::allocate(size_t size) {
  79   size_t byte_size = size * sizeof(void*);
  80   void* data = NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC);
  81   return new (data) BufferNode;
  82 }
  83 
  84 void BufferNode::deallocate(BufferNode* node) {
  85   node->~BufferNode();
  86   FREE_C_HEAP_ARRAY(char, node);
  87 }
  88 
  89 BufferNode::Allocator::Allocator(const char* name, size_t buffer_size) :
  90   _buffer_size(buffer_size),
  91   _pending_list(),
  92   _free_list(),
  93   _pending_count(0),
  94   _free_count(0),
  95   _transfer_lock(false)
  96 {
  97   strncpy(_name, name, sizeof(_name));
  98   _name[sizeof(_name) - 1] = '\0';
  99 }
 100 
 101 BufferNode::Allocator::~Allocator() {
 102   delete_list(_free_list.pop_all());
 103   delete_list(_pending_list.pop_all());
 104 }
 105 
 106 void BufferNode::Allocator::delete_list(BufferNode* list) {
 107   while (list != NULL) {
 108     BufferNode* next = list->next();
 109     DEBUG_ONLY(list->set_next(NULL);)
 110     BufferNode::deallocate(list);
 111     list = next;
 112   }
 113 }
 114 
 115 size_t BufferNode::Allocator::free_count() const {
 116   return Atomic::load(&_free_count);
 117 }




  77 
  78 BufferNode* BufferNode::allocate(size_t size) {
  79   size_t byte_size = size * sizeof(void*);
  80   void* data = NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC);
  81   return new (data) BufferNode;
  82 }
  83 
  84 void BufferNode::deallocate(BufferNode* node) {
  85   node->~BufferNode();
  86   FREE_C_HEAP_ARRAY(char, node);
  87 }
  88 
  89 BufferNode::Allocator::Allocator(const char* name, size_t buffer_size) :
  90   _buffer_size(buffer_size),
  91   _pending_list(),
  92   _free_list(),
  93   _pending_count(0),
  94   _free_count(0),
  95   _transfer_lock(false)
  96 {
  97   strncpy(_name, name, sizeof(_name) - 1);
  98   _name[sizeof(_name) - 1] = '\0';
  99 }
 100 
 101 BufferNode::Allocator::~Allocator() {
 102   delete_list(_free_list.pop_all());
 103   delete_list(_pending_list.pop_all());
 104 }
 105 
 106 void BufferNode::Allocator::delete_list(BufferNode* list) {
 107   while (list != NULL) {
 108     BufferNode* next = list->next();
 109     DEBUG_ONLY(list->set_next(NULL);)
 110     BufferNode::deallocate(list);
 111     list = next;
 112   }
 113 }
 114 
 115 size_t BufferNode::Allocator::free_count() const {
 116   return Atomic::load(&_free_count);
 117 }


< prev index next >