< prev index next >

src/hotspot/share/gc/shared/workerDataArray.inline.hpp

Print this page




  75 
  76 template <typename T>
  77 void WorkerDataArray<T>::add_thread_work_item(uint worker_i, size_t value, uint index) {
  78   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  79   assert(_thread_work_items[index] != NULL, "No sub count");
  80   _thread_work_items[index]->add(worker_i, value);
  81 }
  82 
  83 template <typename T>
  84 void WorkerDataArray<T>::set_or_add_thread_work_item(uint worker_i, size_t value, uint index) {
  85   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  86   assert(_thread_work_items[index] != NULL, "No sub count");
  87   if (_thread_work_items[index]->get(worker_i) == _thread_work_items[index]->uninitialized()) {
  88     _thread_work_items[index]->set(worker_i, value);
  89   } else {
  90     _thread_work_items[index]->add(worker_i, value);
  91   }
  92 }
  93 
  94 template <typename T>
  95 size_t WorkerDataArray<T>::get_thread_work_item(uint worker_i, uint index) {
  96   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  97   assert(_thread_work_items[index] != NULL, "No sub count");
  98   return _thread_work_items[index]->get(worker_i);
  99 }
 100 
 101 template <typename T>
 102 void WorkerDataArray<T>::add(uint worker_i, T value) {
 103   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
 104   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
 105   _data[worker_i] += value;
 106 }
 107 
 108 template <typename T>
 109 double WorkerDataArray<T>::average() const {
 110   uint contributing_threads = 0;
 111   for (uint i = 0; i < _length; ++i) {
 112     if (get(i) != uninitialized()) {
 113       contributing_threads++;
 114     }
 115   }
 116   if (contributing_threads == 0) {
 117     return 0.0;
 118   }
 119   return sum() / (double) contributing_threads;
 120 }
 121 




  75 
  76 template <typename T>
  77 void WorkerDataArray<T>::add_thread_work_item(uint worker_i, size_t value, uint index) {
  78   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  79   assert(_thread_work_items[index] != NULL, "No sub count");
  80   _thread_work_items[index]->add(worker_i, value);
  81 }
  82 
  83 template <typename T>
  84 void WorkerDataArray<T>::set_or_add_thread_work_item(uint worker_i, size_t value, uint index) {
  85   assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
  86   assert(_thread_work_items[index] != NULL, "No sub count");
  87   if (_thread_work_items[index]->get(worker_i) == _thread_work_items[index]->uninitialized()) {
  88     _thread_work_items[index]->set(worker_i, value);
  89   } else {
  90     _thread_work_items[index]->add(worker_i, value);
  91   }
  92 }
  93 
  94 template <typename T>







  95 void WorkerDataArray<T>::add(uint worker_i, T value) {
  96   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
  97   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
  98   _data[worker_i] += value;
  99 }
 100 
 101 template <typename T>
 102 double WorkerDataArray<T>::average() const {
 103   uint contributing_threads = 0;
 104   for (uint i = 0; i < _length; ++i) {
 105     if (get(i) != uninitialized()) {
 106       contributing_threads++;
 107     }
 108   }
 109   if (contributing_threads == 0) {
 110     return 0.0;
 111   }
 112   return sum() / (double) contributing_threads;
 113 }
 114 


< prev index next >