src/hotspot/share/runtime/thread.hpp
changeset 51511 eb8d5aeabab3
parent 51376 181e6a03249b
child 51530 1f0b605bdc28
equal deleted inserted replaced
51510:6b0012622443 51511:eb8d5aeabab3
   101 //       - GangWorker
   101 //       - GangWorker
   102 //       - GCTaskThread
   102 //       - GCTaskThread
   103 //   - JavaThread
   103 //   - JavaThread
   104 //     - various subclasses eg CompilerThread, ServiceThread
   104 //     - various subclasses eg CompilerThread, ServiceThread
   105 //   - WatcherThread
   105 //   - WatcherThread
       
   106 //   - JfrSamplerThread
   106 
   107 
   107 class Thread: public ThreadShadow {
   108 class Thread: public ThreadShadow {
   108   friend class VMStructs;
   109   friend class VMStructs;
   109   friend class JVMCIVMStructs;
   110   friend class JVMCIVMStructs;
   110  private:
   111  private:
   774  private:
   775  private:
   775   char* _name;
   776   char* _name;
   776   // log JavaThread being processed by oops_do
   777   // log JavaThread being processed by oops_do
   777   JavaThread* _processed_thread;
   778   JavaThread* _processed_thread;
   778   uint _gc_id; // The current GC id when a thread takes part in GC
   779   uint _gc_id; // The current GC id when a thread takes part in GC
       
   780   NamedThread* volatile _next_named_thread;
       
   781 
       
   782   class List;
       
   783   static List _the_list;
   779 
   784 
   780  public:
   785  public:
   781   NamedThread();
   786   NamedThread();
   782   ~NamedThread();
   787   ~NamedThread();
   783   // May only be called once per thread.
   788   // May only be called once per thread.
   789   void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
   794   void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
   790   virtual void print_on(outputStream* st) const;
   795   virtual void print_on(outputStream* st) const;
   791 
   796 
   792   void set_gc_id(uint gc_id) { _gc_id = gc_id; }
   797   void set_gc_id(uint gc_id) { _gc_id = gc_id; }
   793   uint gc_id() { return _gc_id; }
   798   uint gc_id() { return _gc_id; }
       
   799 
       
   800   class Iterator;
       
   801 };
       
   802 
       
   803 // Provides iteration over the list of NamedThreads.  Because list
       
   804 // management occurs in the NamedThread constructor and destructor,
       
   805 // entries in the list may not be fully constructed instances of a
       
   806 // derived class.  Threads created after an iterator is constructed
       
   807 // will not be visited by the iterator.  The scope of an iterator is a
       
   808 // critical section; there must be no safepoint checks in that scope.
       
   809 class NamedThread::Iterator : public StackObj {
       
   810   uint _protect_enter;
       
   811   NamedThread* _current;
       
   812 
       
   813   // Noncopyable.
       
   814   Iterator(const Iterator&);
       
   815   Iterator& operator=(const Iterator&);
       
   816 
       
   817 public:
       
   818   Iterator();
       
   819   ~Iterator();
       
   820 
       
   821   bool end() const { return _current == NULL; }
       
   822   NamedThread* current() const { return _current; }
       
   823   void step();
   794 };
   824 };
   795 
   825 
   796 // Worker threads are named and have an id of an assigned work.
   826 // Worker threads are named and have an id of an assigned work.
   797 class WorkerThread: public NamedThread {
   827 class WorkerThread: public NamedThread {
   798  private:
   828  private: