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
--- 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: