--- a/src/hotspot/share/runtime/thread.hpp Thu Aug 23 12:57:40 2018 -0700
+++ b/src/hotspot/share/runtime/thread.hpp Thu Aug 23 18:14:53 2018 -0400
@@ -103,6 +103,7 @@
// - JavaThread
// - various subclasses eg CompilerThread, ServiceThread
// - WatcherThread
+// - JfrSamplerThread
class Thread: public ThreadShadow {
friend class VMStructs;
@@ -776,6 +777,10 @@
// log JavaThread being processed by oops_do
JavaThread* _processed_thread;
uint _gc_id; // The current GC id when a thread takes part in GC
+ NamedThread* volatile _next_named_thread;
+
+ class List;
+ static List _the_list;
public:
NamedThread();
@@ -791,6 +796,31 @@
void set_gc_id(uint gc_id) { _gc_id = gc_id; }
uint gc_id() { return _gc_id; }
+
+ class Iterator;
+};
+
+// Provides iteration over the list of NamedThreads. Because list
+// management occurs in the NamedThread constructor and destructor,
+// entries in the list may not be fully constructed instances of a
+// derived class. Threads created after an iterator is constructed
+// will not be visited by the iterator. The scope of an iterator is a
+// critical section; there must be no safepoint checks in that scope.
+class NamedThread::Iterator : public StackObj {
+ uint _protect_enter;
+ NamedThread* _current;
+
+ // Noncopyable.
+ Iterator(const Iterator&);
+ Iterator& operator=(const Iterator&);
+
+public:
+ Iterator();
+ ~Iterator();
+
+ bool end() const { return _current == NULL; }
+ NamedThread* current() const { return _current; }
+ void step();
};
// Worker threads are named and have an id of an assigned work.