mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8209850: Allow NamedThreads to use GlobalCounter critical sections
Add NamedThreads iterator and make GlobalCounter use it. Reviewed-by: eosterlund, rehn
This commit is contained in:
parent
8b138c684a
commit
23f0fb4cde
11 changed files with 458 additions and 69 deletions
|
@ -103,6 +103,7 @@ class WorkerThread;
|
|||
// - JavaThread
|
||||
// - various subclasses eg CompilerThread, ServiceThread
|
||||
// - WatcherThread
|
||||
// - JfrSamplerThread
|
||||
|
||||
class Thread: public ThreadShadow {
|
||||
friend class VMStructs;
|
||||
|
@ -776,6 +777,10 @@ class NamedThread: public Thread {
|
|||
// 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 @@ class NamedThread: public Thread {
|
|||
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue