< prev index next >

test/hotspot/gtest/gc/shared/test_ptrQueueBufferAllocator.cpp

Print this page




 140                   BufferNode::Allocator* allocator,
 141                   CompletedList* cbl,
 142                   volatile size_t* total_allocations,
 143                   volatile bool* continue_running) :
 144     JavaTestThread(post),
 145     _allocator(allocator),
 146     _cbl(cbl),
 147     _total_allocations(total_allocations),
 148     _continue_running(continue_running),
 149     _allocations(0)
 150   {}
 151 
 152   virtual void main_run() {
 153     while (Atomic::load_acquire(_continue_running)) {
 154       BufferNode* node = _allocator->allocate();
 155       _cbl->push(node);
 156       ++_allocations;
 157       ThreadBlockInVM tbiv(this); // Safepoint check.
 158     }
 159     tty->print_cr("allocations: " SIZE_FORMAT, _allocations);
 160     Atomic::add(_allocations, _total_allocations);
 161   }
 162 };
 163 
 164 // Simulate a GC thread, taking buffers from the completed buffer list
 165 // and returning them to the allocator.
 166 class BufferNode::TestSupport::ProcessorThread : public JavaTestThread {
 167   BufferNode::Allocator* _allocator;
 168   CompletedList* _cbl;
 169   volatile bool* _continue_running;
 170 
 171 public:
 172   ProcessorThread(Semaphore* post,
 173                   BufferNode::Allocator* allocator,
 174                   CompletedList* cbl,
 175                   volatile bool* continue_running) :
 176     JavaTestThread(post),
 177     _allocator(allocator),
 178     _cbl(cbl),
 179     _continue_running(continue_running)
 180   {}




 140                   BufferNode::Allocator* allocator,
 141                   CompletedList* cbl,
 142                   volatile size_t* total_allocations,
 143                   volatile bool* continue_running) :
 144     JavaTestThread(post),
 145     _allocator(allocator),
 146     _cbl(cbl),
 147     _total_allocations(total_allocations),
 148     _continue_running(continue_running),
 149     _allocations(0)
 150   {}
 151 
 152   virtual void main_run() {
 153     while (Atomic::load_acquire(_continue_running)) {
 154       BufferNode* node = _allocator->allocate();
 155       _cbl->push(node);
 156       ++_allocations;
 157       ThreadBlockInVM tbiv(this); // Safepoint check.
 158     }
 159     tty->print_cr("allocations: " SIZE_FORMAT, _allocations);
 160     Atomic::add(_total_allocations, _allocations);
 161   }
 162 };
 163 
 164 // Simulate a GC thread, taking buffers from the completed buffer list
 165 // and returning them to the allocator.
 166 class BufferNode::TestSupport::ProcessorThread : public JavaTestThread {
 167   BufferNode::Allocator* _allocator;
 168   CompletedList* _cbl;
 169   volatile bool* _continue_running;
 170 
 171 public:
 172   ProcessorThread(Semaphore* post,
 173                   BufferNode::Allocator* allocator,
 174                   CompletedList* cbl,
 175                   volatile bool* continue_running) :
 176     JavaTestThread(post),
 177     _allocator(allocator),
 178     _cbl(cbl),
 179     _continue_running(continue_running)
 180   {}


< prev index next >