Skip to content
Permalink
Browse files

8264742: member variable _monitor of MonitorLocker is redundant

Reviewed-by: coleenp, dholmes, phh
  • Loading branch information
Xin Liu authored and Paul Hohensee committed Apr 7, 2021
1 parent 7a99a98 commit 774e5ae0099f3b2b713116a88a0deb6a9fba2dec
Showing with 14 additions and 10 deletions.
  1. +14 −10 src/hotspot/share/runtime/mutexLocker.hpp
@@ -198,7 +198,6 @@ void assert_locked_or_safepoint_or_handshake(const Mutex* lock, const JavaThread
class MutexLocker: public StackObj {
protected:
Mutex* _mutex;
private:
public:
MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex) {
@@ -242,36 +241,41 @@ class MutexLocker: public StackObj {

class MonitorLocker: public MutexLocker {
Mutex::SafepointCheckFlag _flag;
Monitor* _monitor;

protected:
Monitor* as_monitor() const {
return static_cast<Monitor*>(_mutex);
}

public:
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
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) :
MutexLocker(thread, monitor, flag), _flag(flag), _monitor(monitor) {
MutexLocker(thread, monitor, flag), _flag(flag) {
// 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 as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
if (_flag == Mutex::_safepoint_check_flag) {
return _monitor->wait(timeout, as_suspend_equivalent);
return as_monitor()->wait(timeout, as_suspend_equivalent);
} else {
return _monitor->wait_without_safepoint_check(timeout);
return as_monitor()->wait_without_safepoint_check(timeout);
}
return false;
}

void notify_all() {
_monitor->notify_all();
as_monitor()->notify_all();
}

void notify() {
_monitor->notify();
as_monitor()->notify();
}
};

1 comment on commit 774e5ae

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 774e5ae Apr 7, 2021

Please sign in to comment.