< prev index next >
src/hotspot/share/runtime/mutexLocker.hpp
Print this page
@@ -140,11 +140,11 @@
extern Mutex* MetaspaceExpand_lock; // protects Metaspace virtualspace and chunk expansions
extern Mutex* ClassLoaderDataGraph_lock; // protects CLDG list, needed for concurrent unloading
-extern Monitor* CodeHeapStateAnalytics_lock; // lock print functions against concurrent analyze functions.
+extern Mutex* CodeHeapStateAnalytics_lock; // lock print functions against concurrent analyze functions.
// Only used locally in PrintCodeCacheLayout processing.
#if INCLUDE_JVMCI
extern Monitor* JVMCI_lock; // Monitor to control initialization of JVMCI
#endif
@@ -169,25 +169,25 @@
char *lock_name(Mutex *mutex);
// for debugging: check that we're already owning this lock (or are at a safepoint)
#ifdef ASSERT
-void assert_locked_or_safepoint(const Monitor * lock);
-void assert_locked_or_safepoint_weak(const Monitor * lock);
-void assert_lock_strong(const Monitor * lock);
+void assert_locked_or_safepoint(const Mutex* lock);
+void assert_locked_or_safepoint_weak(const Mutex* lock);
+void assert_lock_strong(const Mutex* lock);
#else
#define assert_locked_or_safepoint(lock)
#define assert_locked_or_safepoint_weak(lock)
#define assert_lock_strong(lock)
#endif
class MutexLocker: public StackObj {
protected:
- Monitor* _mutex;
+ Mutex* _mutex;
private:
public:
- MutexLocker(Monitor* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
+ MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex) {
bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag;
if (_mutex != NULL) {
assert(_mutex->rank() > Mutex::special || no_safepoint_check,
"Mutexes with rank special or lower should not do safepoint checks");
@@ -197,11 +197,11 @@
_mutex->lock();
}
}
}
- MutexLocker(Monitor* mutex, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
+ MutexLocker(Mutex* mutex, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex) {
bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag;
if (_mutex != NULL) {
assert(_mutex->rank() > Mutex::special || no_safepoint_check,
"Mutexes with rank special or lower should not do safepoint checks");
@@ -225,39 +225,40 @@
// wait/notify as well which are delegated to the underlying Monitor.
// It also disallows NULL.
class MonitorLocker: public MutexLocker {
Mutex::SafepointCheckFlag _flag;
+ Monitor* _monitor;
public:
MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
- MutexLocker(monitor, flag), _flag(flag) {
+ MutexLocker(monitor, flag), _flag(flag), _monitor(monitor) {
// Superclass constructor did locking
- assert(_mutex != NULL, "NULL monitor not allowed");
+ assert(_monitor != NULL, "NULL monitor not allowed");
}
MonitorLocker(Monitor* monitor, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
- MutexLocker(monitor, thread, flag), _flag(flag) {
+ MutexLocker(monitor, thread, flag), _flag(flag), _monitor(monitor) {
// Superclass constructor did locking
- assert(_mutex != NULL, "NULL monitor not allowed");
+ assert(_monitor != NULL, "NULL monitor not allowed");
}
bool wait(long timeout = 0,
bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
if (_flag == Mutex::_safepoint_check_flag) {
- return _mutex->wait(timeout, as_suspend_equivalent);
+ return _monitor->wait(timeout, as_suspend_equivalent);
} else {
- return _mutex->wait_without_safepoint_check(timeout);
+ return _monitor->wait_without_safepoint_check(timeout);
}
return false;
}
void notify_all() {
- _mutex->notify_all();
+ _monitor->notify_all();
}
void notify() {
- _mutex->notify();
+ _monitor->notify();
}
};
// A GCMutexLocker is usually initialized with a mutex that is
@@ -266,27 +267,27 @@
// GC's. Thus, it must acquire the mutex if GC is not in progress, but not
// if GC is in progress (since the mutex is already held on its behalf.)
class GCMutexLocker: public StackObj {
private:
- Monitor* _mutex;
+ Mutex* _mutex;
bool _locked;
public:
- GCMutexLocker(Monitor* mutex);
+ GCMutexLocker(Mutex* mutex);
~GCMutexLocker() { if (_locked) _mutex->unlock(); }
};
// A MutexUnlocker temporarily exits a previously
// entered mutex for the scope which contains the unlocker.
class MutexUnlocker: StackObj {
private:
- Monitor* _mutex;
+ Mutex* _mutex;
bool _no_safepoint_check;
public:
- MutexUnlocker(Monitor* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
+ MutexUnlocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex),
_no_safepoint_check(flag) {
_mutex->unlock();
}
< prev index next >