mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8264742: member variable _monitor of MonitorLocker is redundant
Reviewed-by: coleenp, dholmes, phh
This commit is contained in:
parent
7a99a9874b
commit
774e5ae009
1 changed files with 14 additions and 10 deletions
|
@ -198,7 +198,6 @@ void assert_locked_or_safepoint_or_handshake(const Mutex* lock, const JavaThread
|
||||||
class MutexLocker: public StackObj {
|
class MutexLocker: public StackObj {
|
||||||
protected:
|
protected:
|
||||||
Mutex* _mutex;
|
Mutex* _mutex;
|
||||||
private:
|
|
||||||
public:
|
public:
|
||||||
MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
||||||
_mutex(mutex) {
|
_mutex(mutex) {
|
||||||
|
@ -242,36 +241,41 @@ class MutexLocker: public StackObj {
|
||||||
|
|
||||||
class MonitorLocker: public MutexLocker {
|
class MonitorLocker: public MutexLocker {
|
||||||
Mutex::SafepointCheckFlag _flag;
|
Mutex::SafepointCheckFlag _flag;
|
||||||
Monitor* _monitor;
|
|
||||||
|
protected:
|
||||||
|
Monitor* as_monitor() const {
|
||||||
|
return static_cast<Monitor*>(_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
||||||
MutexLocker(monitor, flag), _flag(flag), _monitor(monitor) {
|
MutexLocker(monitor, flag), _flag(flag) {
|
||||||
// Superclass constructor did locking
|
// Superclass constructor did locking
|
||||||
assert(_monitor != NULL, "NULL monitor not allowed");
|
assert(monitor != NULL, "NULL monitor not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitorLocker(Thread* thread, Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
MonitorLocker(Thread* thread, Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
|
||||||
MutexLocker(thread, monitor, flag), _flag(flag), _monitor(monitor) {
|
MutexLocker(thread, monitor, flag), _flag(flag) {
|
||||||
// Superclass constructor did locking
|
// Superclass constructor did locking
|
||||||
assert(_monitor != NULL, "NULL monitor not allowed");
|
assert(monitor != NULL, "NULL monitor not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wait(int64_t timeout = 0,
|
bool wait(int64_t timeout = 0,
|
||||||
bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
|
bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
|
||||||
if (_flag == Mutex::_safepoint_check_flag) {
|
if (_flag == Mutex::_safepoint_check_flag) {
|
||||||
return _monitor->wait(timeout, as_suspend_equivalent);
|
return as_monitor()->wait(timeout, as_suspend_equivalent);
|
||||||
} else {
|
} else {
|
||||||
return _monitor->wait_without_safepoint_check(timeout);
|
return as_monitor()->wait_without_safepoint_check(timeout);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_all() {
|
void notify_all() {
|
||||||
_monitor->notify_all();
|
as_monitor()->notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify() {
|
void notify() {
|
||||||
_monitor->notify();
|
as_monitor()->notify();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue