Skip to content

Commit 334c609

Browse files
committed
8230845: ZGC: Implement ZLock using os::PlatformMutex
Reviewed-by: stefank
1 parent 5e7e0e7 commit 334c609

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/hotspot/share/gc/z/zLock.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,16 +25,13 @@
2525
#define SHARE_GC_Z_ZLOCK_HPP
2626

2727
#include "memory/allocation.hpp"
28-
#include <pthread.h>
28+
#include "runtime/os.hpp"
2929

3030
class ZLock {
3131
private:
32-
pthread_mutex_t _lock;
32+
os::PlatformMutex _lock;
3333

3434
public:
35-
ZLock();
36-
~ZLock();
37-
3835
void lock();
3936
bool try_lock();
4037
void unlock();

src/hotspot/share/gc/z/zLock.inline.hpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,27 +26,20 @@
2626

2727
#include "gc/z/zLock.hpp"
2828
#include "runtime/atomic.hpp"
29+
#include "runtime/os.inline.hpp"
2930
#include "runtime/thread.hpp"
3031
#include "utilities/debug.hpp"
3132

32-
inline ZLock::ZLock() {
33-
pthread_mutex_init(&_lock, NULL);
34-
}
35-
36-
inline ZLock::~ZLock() {
37-
pthread_mutex_destroy(&_lock);
38-
}
39-
4033
inline void ZLock::lock() {
41-
pthread_mutex_lock(&_lock);
34+
_lock.lock();
4235
}
4336

4437
inline bool ZLock::try_lock() {
45-
return pthread_mutex_trylock(&_lock) == 0;
38+
return _lock.try_lock();
4639
}
4740

4841
inline void ZLock::unlock() {
49-
pthread_mutex_unlock(&_lock);
42+
_lock.unlock();
5043
}
5144

5245
inline ZReentrantLock::ZReentrantLock() :

0 commit comments

Comments
 (0)