8212074: Add method to peek the remaining tasks in task queues
authorzgu
Mon, 15 Oct 2018 11:53:15 -0400
changeset 52122 cb20bf10cfbd
parent 52121 934969c63223
child 52123 e5adee94d20d
child 52128 1e0cdaf980f3
child 56968 de6373676c08
8212074: Add method to peek the remaining tasks in task queues Summary: Add methods for implementing new task termination protocol Reviewed-by: tschatzl, shade, rkennke
src/hotspot/share/gc/shared/taskqueue.hpp
--- a/src/hotspot/share/gc/shared/taskqueue.hpp	Mon Oct 15 22:47:03 2018 +0800
+++ b/src/hotspot/share/gc/shared/taskqueue.hpp	Mon Oct 15 11:53:15 2018 -0400
@@ -370,6 +370,8 @@
 public:
   // Returns "true" if some TaskQueue in the set contains a task.
   virtual bool peek() = 0;
+  // Tasks in queue
+  virtual uint tasks() const = 0;
 };
 
 template <MEMFLAGS F> class TaskQueueSetSuperImpl: public CHeapObj<F>, public TaskQueueSetSuper {
@@ -399,6 +401,7 @@
   bool steal(uint queue_num, E& t);
 
   bool peek();
+  uint tasks() const;
 
   uint size() const { return _n; }
 };
@@ -424,6 +427,15 @@
   return false;
 }
 
+template<class T, MEMFLAGS F>
+uint GenericTaskQueueSet<T, F>::tasks() const {
+  uint 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: