Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264742: member variable _monitor of MonitorLocker is redundant #3350

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -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();
}
};

ProTip! Use n and p to navigate between commits in a pull request.