You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/06/24 09:03:04 UTC
logging-log4j2 git commit: Javadoc and refine.
Repository: logging-log4j2
Updated Branches:
refs/heads/AutoCloseableLock 72d9978c6 -> d1b615179
Javadoc and refine.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d1b61517
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d1b61517
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d1b61517
Branch: refs/heads/AutoCloseableLock
Commit: d1b615179f52cc2262dae8cc8dd86c6ff9056862
Parents: 72d9978
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Jun 24 02:02:59 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Jun 24 02:02:59 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/util/AutoCloseableLock.java | 36 +++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d1b61517/log4j-api/src/main/java/org/apache/logging/log4j/util/AutoCloseableLock.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/AutoCloseableLock.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/AutoCloseableLock.java
index 137afb2..4253a23 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/AutoCloseableLock.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/AutoCloseableLock.java
@@ -28,47 +28,75 @@ import java.util.concurrent.locks.ReentrantLock;
* @since 2.6.2
*/
public final class AutoCloseableLock implements AutoCloseable, Serializable {
-
+
private static final long serialVersionUID = 1L;
public static AutoCloseableLock wrap(final Lock lock) {
return new AutoCloseableLock(lock);
}
-
+
public static AutoCloseableLock forReentrantLock() {
return wrap(new ReentrantLock());
}
-
+
private final Lock lock;
- public AutoCloseableLock(final Lock lock) {
+ private AutoCloseableLock(final Lock lock) {
Objects.requireNonNull(lock, "lock");
this.lock = lock;
}
+ /**
+ * Delegates to {@link Lock#unlock()}.
+ */
@Override
public void close() {
this.lock.unlock();
}
+ /**
+ * Delegates to {@link Lock#lock()}.
+ *
+ * @return
+ */
public AutoCloseableLock lock() {
this.lock.lock();
return this;
}
+ /**
+ * Delegates to {@link Lock#tryLock()}, do NOT use in a try block.
+ *
+ * @return
+ */
public boolean tryLock() {
return this.lock.tryLock();
}
+ /**
+ * Delegates to {@link Lock#lockInterruptibly()}, use in a try block.
+ *
+ * @return
+ */
public AutoCloseableLock lockInterruptibly() throws InterruptedException {
this.lock.lockInterruptibly();
return this;
}
+ /**
+ * Delegates to {@link Lock#newCondition()}.
+ *
+ * @return
+ */
public Condition newCondition() {
return this.lock.newCondition();
}
+ /**
+ * Delegates to {@link Lock#unlock()}.
+ *
+ * @return
+ */
public void unlock() {
this.lock.unlock();
}