< prev index next >

src/share/vm/utilities/taskqueue.hpp

Print this page

        

@@ -498,10 +498,11 @@
 protected:
   static int randomParkAndMiller(int* seed0);
 public:
   // Returns "true" if some TaskQueue in the set contains a task.
   virtual bool peek() = 0;
+  virtual size_t tasks() = 0;
 };
 
 template <MEMFLAGS F> class TaskQueueSetSuperImpl: public CHeapObj<F>, public TaskQueueSetSuper {
 };
 

@@ -534,10 +535,13 @@
   // succeeds, returns "true" and sets "t" to the stolen task, otherwise returns
   // false.
   bool steal(uint queue_num, int* seed, E& t);
 
   bool peek();
+  size_t tasks();
+
+  uint size() const { return _n; }
 };
 
 template<class T, MEMFLAGS F> void
 GenericTaskQueueSet<T, F>::register_queue(uint i, T* q) {
   assert(i < _n, "index out of range.");

@@ -591,10 +595,19 @@
       return true;
   }
   return false;
 }
 
+template<class T, MEMFLAGS F>
+size_t GenericTaskQueueSet<T, F>::tasks() {
+  size_t n = 0;
+  for (uint j = 0; j < _n; j++) {
+    n += _queues[j]->size();
+  }
+  return n;
+}
+
 // When to terminate from the termination protocol.
 class TerminatorTerminator: public CHeapObj<mtInternal> {
 public:
   virtual bool should_exit_termination() = 0;
 };

@@ -603,11 +616,11 @@
 // TaskQueueSet's for work stealing.
 
 #undef TRACESPINNING
 
 class ParallelTaskTerminator: public StackObj {
-private:
+protected:
   int _n_threads;
   TaskQueueSetSuper* _queue_set;
   char _pad_before[DEFAULT_CACHE_LINE_SIZE];
   int _offered_termination;
   char _pad_after[DEFAULT_CACHE_LINE_SIZE];

@@ -631,11 +644,11 @@
 
   // The current thread has no work, and is ready to terminate if everyone
   // else is.  If returns "true", all threads are terminated.  If returns
   // "false", available work has been observed in one of the task queues,
   // so the global task is not complete.
-  bool offer_termination() {
+  virtual bool offer_termination() {
     return offer_termination(NULL);
   }
 
   // As above, but it also terminates if the should_exit_termination()
   // method of the terminator parameter returns true. If terminator is
< prev index next >