< prev index next >

src/hotspot/share/runtime/mutexLocker.hpp

concurrent root iterator v3

181     _mutex->lock();                                                                                                                  
182   }                                                                                                                                  
183 
184   // Overloaded constructor passing current thread                                                                                   
185   MutexLocker(Monitor * mutex, Thread *thread) {                                                                                     
186     assert(mutex->rank() != Mutex::special,                                                                                          
187       "Special ranked mutex should only use MutexLockerEx");                                                                         
188     _mutex = mutex;                                                                                                                  
189     _mutex->lock(thread);                                                                                                            
190   }                                                                                                                                  
191 
192   ~MutexLocker() {                                                                                                                   
193     _mutex->unlock();                                                                                                                
194   }                                                                                                                                  
195 
196 };                                                                                                                                   
197 
198 // for debugging: check that we're already owning this lock (or are at a safepoint)                                                  
199 #ifdef ASSERT                                                                                                                        
200 void assert_locked_or_safepoint(const Monitor * lock);                                                                               
                                                                                                                                     
201 void assert_lock_strong(const Monitor * lock);                                                                                       
202 #else                                                                                                                                
203 #define assert_locked_or_safepoint(lock)                                                                                             
                                                                                                                                     
204 #define assert_lock_strong(lock)                                                                                                     
205 #endif                                                                                                                               
206 
207 // A MutexLockerEx behaves like a MutexLocker when its constructor is                                                                
208 // called with a Mutex.  Unlike a MutexLocker, its constructor can also be                                                           
209 // called with NULL, in which case the MutexLockerEx is a no-op.  There                                                              
210 // is also a corresponding MutexUnlockerEx.  We want to keep the                                                                     
211 // basic MutexLocker as fast as possible.  MutexLockerEx can also lock                                                               
212 // without safepoint check.                                                                                                          
213 
214 class MutexLockerEx: public StackObj {                                                                                               
215  private:                                                                                                                            
216   Monitor * _mutex;                                                                                                                  
217  public:                                                                                                                             
218   MutexLockerEx(Monitor * mutex, bool no_safepoint_check = !Mutex::_no_safepoint_check_flag) {                                       
219     _mutex = mutex;                                                                                                                  
220     if (_mutex != NULL) {                                                                                                            
221       assert(mutex->rank() > Mutex::special || no_safepoint_check,                                                                   
222         "Mutexes with rank special or lower should not do safepoint checks");                                                        

181     _mutex->lock();
182   }
183 
184   // Overloaded constructor passing current thread
185   MutexLocker(Monitor * mutex, Thread *thread) {
186     assert(mutex->rank() != Mutex::special,
187       "Special ranked mutex should only use MutexLockerEx");
188     _mutex = mutex;
189     _mutex->lock(thread);
190   }
191 
192   ~MutexLocker() {
193     _mutex->unlock();
194   }
195 
196 };
197 
198 // for debugging: check that we're already owning this lock (or are at a safepoint)
199 #ifdef ASSERT
200 void assert_locked_or_safepoint(const Monitor * lock);
201 void assert_locked_or_safepoint_weak(const Monitor * lock);
202 void assert_lock_strong(const Monitor * lock);
203 #else
204 #define assert_locked_or_safepoint(lock)
205 #define assert_locked_or_safepoint_weak(lock)
206 #define assert_lock_strong(lock)
207 #endif
208 
209 // A MutexLockerEx behaves like a MutexLocker when its constructor is
210 // called with a Mutex.  Unlike a MutexLocker, its constructor can also be
211 // called with NULL, in which case the MutexLockerEx is a no-op.  There
212 // is also a corresponding MutexUnlockerEx.  We want to keep the
213 // basic MutexLocker as fast as possible.  MutexLockerEx can also lock
214 // without safepoint check.
215 
216 class MutexLockerEx: public StackObj {
217  private:
218   Monitor * _mutex;
219  public:
220   MutexLockerEx(Monitor * mutex, bool no_safepoint_check = !Mutex::_no_safepoint_check_flag) {
221     _mutex = mutex;
222     if (_mutex != NULL) {
223       assert(mutex->rank() > Mutex::special || no_safepoint_check,
224         "Mutexes with rank special or lower should not do safepoint checks");
< prev index next >