< prev index next >

src/share/vm/services/threadService.hpp

Print this page
rev 9081 : imported patch more.patch


 413   }
 414 
 415  public:
 416   static void set_thread_status(JavaThread* java_thread,
 417                                 java_lang_Thread::ThreadStatus state) {
 418     java_lang_Thread::set_thread_status(java_thread->threadObj(), state);
 419   }
 420 
 421   void set_thread_status(java_lang_Thread::ThreadStatus state) {
 422     if (is_alive()) {
 423       set_thread_status(_java_thread, state);
 424     }
 425   }
 426 
 427   JavaThreadStatusChanger(JavaThread* java_thread,
 428                           java_lang_Thread::ThreadStatus state) {
 429     save_old_state(java_thread);
 430     set_thread_status(state);
 431   }
 432 
 433   JavaThreadStatusChanger(JavaThread* java_thread) {
 434     save_old_state(java_thread);
 435   }
 436 
 437   ~JavaThreadStatusChanger() {
 438     set_thread_status(_old_state);
 439   }
 440 
 441   static bool is_alive(JavaThread* java_thread) {
 442     return java_thread != NULL && java_thread->threadObj() != NULL;
 443   }
 444 
 445   bool is_alive() {
 446     return _is_alive;
 447   }
 448 };
 449 
 450 // Change status to waiting on an object  (timed or indefinite)
 451 class JavaThreadInObjectWaitState : public JavaThreadStatusChanger {
 452  private:
 453   ThreadStatistics* _stat;


 525  public:
 526   // java_thread is waiting thread being blocked on monitor reenter.
 527   // Current thread is the notifying thread which holds the monitor.
 528   static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) {
 529     assert((java_thread != NULL), "Java thread should not be null here");
 530     bool active  = false;
 531     if (is_alive(java_thread) && ServiceUtil::visible_oop((oop)obj_m->object())) {
 532       active = contended_enter_begin(java_thread);
 533     }
 534     return active;
 535   }
 536 
 537   static void wait_reenter_end(JavaThread *java_thread, bool active) {
 538     if (active) {
 539       java_thread->get_thread_stat()->contended_enter_end();
 540     }
 541     set_thread_status(java_thread, java_lang_Thread::RUNNABLE);
 542   }
 543 
 544   JavaThreadBlockedOnMonitorEnterState(JavaThread *java_thread, ObjectMonitor *obj_m) :
 545     JavaThreadStatusChanger(java_thread) {
 546     assert((java_thread != NULL), "Java thread should not be null here");
 547     // Change thread status and collect contended enter stats for monitor contended
 548     // enter done for external java world objects and it is contended. All other cases
 549     // like for vm internal objects and for external objects which are not contended
 550     // thread status is not changed and contended enter stat is not collected.
 551     _active = false;
 552     if (is_alive() && ServiceUtil::visible_oop((oop)obj_m->object()) && obj_m->contentions() > 0) {
 553       _stat = java_thread->get_thread_stat();
 554       _active = contended_enter_begin(java_thread);
 555     }
 556   }
 557 
 558   ~JavaThreadBlockedOnMonitorEnterState() {
 559     if (_active) {
 560       _stat->contended_enter_end();
 561     }
 562   }
 563 };
 564 
 565 // Change status to sleeping




 413   }
 414 
 415  public:
 416   static void set_thread_status(JavaThread* java_thread,
 417                                 java_lang_Thread::ThreadStatus state) {
 418     java_lang_Thread::set_thread_status(java_thread->threadObj(), state);
 419   }
 420 
 421   void set_thread_status(java_lang_Thread::ThreadStatus state) {
 422     if (is_alive()) {
 423       set_thread_status(_java_thread, state);
 424     }
 425   }
 426 
 427   JavaThreadStatusChanger(JavaThread* java_thread,
 428                           java_lang_Thread::ThreadStatus state) {
 429     save_old_state(java_thread);
 430     set_thread_status(state);
 431   }
 432 
 433   JavaThreadStatusChanger(JavaThread* java_thread) : _old_state(java_lang_Thread::NEW) {
 434     save_old_state(java_thread);
 435   }
 436 
 437   ~JavaThreadStatusChanger() {
 438     set_thread_status(_old_state);
 439   }
 440 
 441   static bool is_alive(JavaThread* java_thread) {
 442     return java_thread != NULL && java_thread->threadObj() != NULL;
 443   }
 444 
 445   bool is_alive() {
 446     return _is_alive;
 447   }
 448 };
 449 
 450 // Change status to waiting on an object  (timed or indefinite)
 451 class JavaThreadInObjectWaitState : public JavaThreadStatusChanger {
 452  private:
 453   ThreadStatistics* _stat;


 525  public:
 526   // java_thread is waiting thread being blocked on monitor reenter.
 527   // Current thread is the notifying thread which holds the monitor.
 528   static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) {
 529     assert((java_thread != NULL), "Java thread should not be null here");
 530     bool active = false;
 531     if (is_alive(java_thread) && ServiceUtil::visible_oop((oop)obj_m->object())) {
 532       active = contended_enter_begin(java_thread);
 533     }
 534     return active;
 535   }
 536 
 537   static void wait_reenter_end(JavaThread *java_thread, bool active) {
 538     if (active) {
 539       java_thread->get_thread_stat()->contended_enter_end();
 540     }
 541     set_thread_status(java_thread, java_lang_Thread::RUNNABLE);
 542   }
 543 
 544   JavaThreadBlockedOnMonitorEnterState(JavaThread *java_thread, ObjectMonitor *obj_m) :
 545     _stat(NULL), _active(false), JavaThreadStatusChanger(java_thread) {
 546     assert((java_thread != NULL), "Java thread should not be null here");
 547     // Change thread status and collect contended enter stats for monitor contended
 548     // enter done for external java world objects and it is contended. All other cases
 549     // like for vm internal objects and for external objects which are not contended
 550     // thread status is not changed and contended enter stat is not collected.
 551     _active = false;
 552     if (is_alive() && ServiceUtil::visible_oop((oop)obj_m->object()) && obj_m->contentions() > 0) {
 553       _stat = java_thread->get_thread_stat();
 554       _active = contended_enter_begin(java_thread);
 555     }
 556   }
 557 
 558   ~JavaThreadBlockedOnMonitorEnterState() {
 559     if (_active) {
 560       _stat->contended_enter_end();
 561     }
 562   }
 563 };
 564 
 565 // Change status to sleeping


< prev index next >