< prev index next >

src/hotspot/share/gc/shared/concurrentGCThread.cpp

Print this page




  50 
  51 void ConcurrentGCThread::initialize_in_thread() {
  52   this->record_stack_base_and_size();
  53   this->initialize_named_thread();
  54   this->set_active_handles(JNIHandleBlock::allocate_block());
  55   // From this time Thread::current() should be working.
  56   assert(this == Thread::current(), "just checking");
  57 }
  58 
  59 void ConcurrentGCThread::wait_for_universe_init() {
  60   MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
  61   while (!is_init_completed() && !_should_terminate) {
  62     CGC_lock->wait(Mutex::_no_safepoint_check_flag, 1);
  63   }
  64 }
  65 
  66 void ConcurrentGCThread::terminate() {
  67   assert(_should_terminate, "Should only be called on terminate request.");
  68   // Signal that it is terminated
  69   {
  70     MutexLockerEx mu(Terminator_lock,
  71                      Mutex::_no_safepoint_check_flag);
  72     _has_terminated = true;
  73     Terminator_lock->notify();
  74   }
  75 }
  76 
  77 void ConcurrentGCThread::run() {
  78   initialize_in_thread();
  79   wait_for_universe_init();
  80 
  81   run_service();
  82 
  83   terminate();
  84 }
  85 
  86 void ConcurrentGCThread::stop() {
  87   // it is ok to take late safepoints here, if needed
  88   {
  89     MutexLockerEx mu(Terminator_lock);
  90     assert(!_has_terminated,   "stop should only be called once");
  91     assert(!_should_terminate, "stop should only be called once");


  50 
  51 void ConcurrentGCThread::initialize_in_thread() {
  52   this->record_stack_base_and_size();
  53   this->initialize_named_thread();
  54   this->set_active_handles(JNIHandleBlock::allocate_block());
  55   // From this time Thread::current() should be working.
  56   assert(this == Thread::current(), "just checking");
  57 }
  58 
  59 void ConcurrentGCThread::wait_for_universe_init() {
  60   MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
  61   while (!is_init_completed() && !_should_terminate) {
  62     CGC_lock->wait(Mutex::_no_safepoint_check_flag, 1);
  63   }
  64 }
  65 
  66 void ConcurrentGCThread::terminate() {
  67   assert(_should_terminate, "Should only be called on terminate request.");
  68   // Signal that it is terminated
  69   {
  70     MutexLocker mu(Terminator_lock);

  71     _has_terminated = true;
  72     Terminator_lock->notify();
  73   }
  74 }
  75 
  76 void ConcurrentGCThread::run() {
  77   initialize_in_thread();
  78   wait_for_universe_init();
  79 
  80   run_service();
  81 
  82   terminate();
  83 }
  84 
  85 void ConcurrentGCThread::stop() {
  86   // it is ok to take late safepoints here, if needed
  87   {
  88     MutexLockerEx mu(Terminator_lock);
  89     assert(!_has_terminated,   "stop should only be called once");
  90     assert(!_should_terminate, "stop should only be called once");
< prev index next >