|
@@ -24,7 +24,9 @@ public interface RwLock {
|
|
readLock(RwLockMode.GLOBAL);
|
|
readLock(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Acquire read lock. */
|
|
|
|
|
|
+ /** Acquire read lock.
|
|
|
|
+ * @param lockMode The lock type for acquiring a read lock
|
|
|
|
+ */
|
|
void readLock(RwLockMode lockMode);
|
|
void readLock(RwLockMode lockMode);
|
|
|
|
|
|
/** Acquire read lock, unless interrupted while waiting. */
|
|
/** Acquire read lock, unless interrupted while waiting. */
|
|
@@ -32,7 +34,9 @@ public interface RwLock {
|
|
readLockInterruptibly(RwLockMode.GLOBAL);
|
|
readLockInterruptibly(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Acquire read lock, unless interrupted while waiting. */
|
|
|
|
|
|
+ /** Acquire read lock, unless interrupted while waiting.
|
|
|
|
+ * @param lockMode The lock type for acquiring a read lock
|
|
|
|
+ */
|
|
void readLockInterruptibly(RwLockMode lockMode) throws InterruptedException;
|
|
void readLockInterruptibly(RwLockMode lockMode) throws InterruptedException;
|
|
|
|
|
|
/** Release read lock. */
|
|
/** Release read lock. */
|
|
@@ -50,16 +54,22 @@ public interface RwLock {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Release read lock with operation name.
|
|
* Release read lock with operation name.
|
|
|
|
+ * @param lockMode The lock type for releasing the read lock
|
|
* @param opName Option name.
|
|
* @param opName Option name.
|
|
*/
|
|
*/
|
|
void readUnlock(RwLockMode lockMode, String opName);
|
|
void readUnlock(RwLockMode lockMode, String opName);
|
|
|
|
|
|
- /** Check if the current thread holds read lock. */
|
|
|
|
|
|
+ /** Check if the current thread holds read lock.
|
|
|
|
+ * @return true if the read lock is held by the current thread, else false
|
|
|
|
+ */
|
|
default boolean hasReadLock() {
|
|
default boolean hasReadLock() {
|
|
return hasReadLock(RwLockMode.GLOBAL);
|
|
return hasReadLock(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Check if the current thread holds read lock. */
|
|
|
|
|
|
+ /** Check if the current thread holds read lock.
|
|
|
|
+ * @param lockMode The lock type used to check whether a read lock is held
|
|
|
|
+ * @return true if the read lock is held by the current thread, else false
|
|
|
|
+ */
|
|
boolean hasReadLock(RwLockMode lockMode);
|
|
boolean hasReadLock(RwLockMode lockMode);
|
|
|
|
|
|
/** Acquire write lock. */
|
|
/** Acquire write lock. */
|
|
@@ -67,7 +77,9 @@ public interface RwLock {
|
|
writeLock(RwLockMode.GLOBAL);
|
|
writeLock(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Acquire write lock. */
|
|
|
|
|
|
+ /** Acquire write lock.
|
|
|
|
+ * @param lockMode The lock type for acquiring a write lock
|
|
|
|
+ */
|
|
void writeLock(RwLockMode lockMode);
|
|
void writeLock(RwLockMode lockMode);
|
|
|
|
|
|
/** Acquire write lock, unless interrupted while waiting. */
|
|
/** Acquire write lock, unless interrupted while waiting. */
|
|
@@ -75,7 +87,9 @@ public interface RwLock {
|
|
writeLockInterruptibly(RwLockMode.GLOBAL);
|
|
writeLockInterruptibly(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Acquire write lock, unless interrupted while waiting. */
|
|
|
|
|
|
+ /** Acquire write lock, unless interrupted while waiting.
|
|
|
|
+ * @param lockMode The lock type for acquiring a write lock
|
|
|
|
+ */
|
|
void writeLockInterruptibly(RwLockMode lockMode) throws InterruptedException;
|
|
void writeLockInterruptibly(RwLockMode lockMode) throws InterruptedException;
|
|
|
|
|
|
/** Release write lock. */
|
|
/** Release write lock. */
|
|
@@ -93,15 +107,21 @@ public interface RwLock {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Release write lock with operation name.
|
|
* Release write lock with operation name.
|
|
|
|
+ * @param lockMode The lock type for releasing the write lock
|
|
* @param opName Option name.
|
|
* @param opName Option name.
|
|
*/
|
|
*/
|
|
void writeUnlock(RwLockMode lockMode, String opName);
|
|
void writeUnlock(RwLockMode lockMode, String opName);
|
|
|
|
|
|
- /** Check if the current thread holds write lock. */
|
|
|
|
|
|
+ /** Check if the current thread holds write lock.
|
|
|
|
+ * @return true if the write lock is held by the current thread, else false
|
|
|
|
+ */
|
|
default boolean hasWriteLock() {
|
|
default boolean hasWriteLock() {
|
|
return hasWriteLock(RwLockMode.GLOBAL);
|
|
return hasWriteLock(RwLockMode.GLOBAL);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Check if the current thread holds write lock. */
|
|
|
|
|
|
+ /** Check if the current thread holds write lock.
|
|
|
|
+ * @param lockMode The lock type used to check whether a write lock is held
|
|
|
|
+ * @return true if the write lock is held by the current thread, else false.
|
|
|
|
+ */
|
|
boolean hasWriteLock(RwLockMode lockMode);
|
|
boolean hasWriteLock(RwLockMode lockMode);
|
|
}
|
|
}
|