src/hotspot/share/gc/shared/concurrentGCThread.cpp
changeset 59247 56bf71d64d51
parent 54623 1126f0607c70
child 59290 97d13893ec3c
equal deleted inserted replaced
59246:fcad92f425c5 59247:56bf71d64d51
    49 
    49 
    50   run_service();
    50   run_service();
    51 
    51 
    52   // Signal thread has terminated
    52   // Signal thread has terminated
    53   MonitorLocker ml(Terminator_lock);
    53   MonitorLocker ml(Terminator_lock);
    54   OrderAccess::release_store(&_has_terminated, true);
    54   Atomic::release_store(&_has_terminated, true);
    55   ml.notify_all();
    55   ml.notify_all();
    56 }
    56 }
    57 
    57 
    58 void ConcurrentGCThread::stop() {
    58 void ConcurrentGCThread::stop() {
    59   assert(!should_terminate(), "Invalid state");
    59   assert(!should_terminate(), "Invalid state");
    60   assert(!has_terminated(), "Invalid state");
    60   assert(!has_terminated(), "Invalid state");
    61 
    61 
    62   // Signal thread to terminate
    62   // Signal thread to terminate
    63   OrderAccess::release_store_fence(&_should_terminate, true);
    63   Atomic::release_store_fence(&_should_terminate, true);
    64 
    64 
    65   stop_service();
    65   stop_service();
    66 
    66 
    67   // Wait for thread to terminate
    67   // Wait for thread to terminate
    68   MonitorLocker ml(Terminator_lock);
    68   MonitorLocker ml(Terminator_lock);
    70     ml.wait();
    70     ml.wait();
    71   }
    71   }
    72 }
    72 }
    73 
    73 
    74 bool ConcurrentGCThread::should_terminate() const {
    74 bool ConcurrentGCThread::should_terminate() const {
    75   return OrderAccess::load_acquire(&_should_terminate);
    75   return Atomic::load_acquire(&_should_terminate);
    76 }
    76 }
    77 
    77 
    78 bool ConcurrentGCThread::has_terminated() const {
    78 bool ConcurrentGCThread::has_terminated() const {
    79   return OrderAccess::load_acquire(&_has_terminated);
    79   return Atomic::load_acquire(&_has_terminated);
    80 }
    80 }