Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8246265: ZGC: Introduce ZConditionLock
Reviewed-by: eosterlund, stefank
  • Loading branch information
pliden committed Jun 9, 2020
1 parent 63a3d8f commit cd16b568ce04c3871ad0d0e4901c79fd53f441e1
Showing with 40 additions and 2 deletions.
  1. +15 −1 src/hotspot/share/gc/z/zLock.hpp
  2. +25 −1 src/hotspot/share/gc/z/zLock.inline.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,20 @@ class ZReentrantLock {
bool is_owned() const;
};

class ZConditionLock {
private:
os::PlatformMonitor _lock;

public:
void lock();
bool try_lock();
void unlock();

bool wait(uint64_t millis = 0);
void notify();
void notify_all();
};

template <typename T>
class ZLocker : public StackObj {
private:
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,30 @@ inline bool ZReentrantLock::is_owned() const {
return owner == thread;
}

inline void ZConditionLock::lock() {
_lock.lock();
}

inline bool ZConditionLock::try_lock() {
return _lock.try_lock();
}

inline void ZConditionLock::unlock() {
_lock.unlock();
}

inline bool ZConditionLock::wait(uint64_t millis) {
return _lock.wait(millis) == OS_OK;
}

inline void ZConditionLock::notify() {
_lock.notify();
}

inline void ZConditionLock::notify_all() {
_lock.notify_all();
}

template <typename T>
inline ZLocker<T>::ZLocker(T* lock) :
_lock(lock) {

0 comments on commit cd16b56

Please sign in to comment.