Package org.eclipse.aether.named.support
Class ReadWriteLockNamedLock
- java.lang.Object
-
- org.eclipse.aether.named.support.NamedLockSupport
-
- org.eclipse.aether.named.support.ReadWriteLockNamedLock
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,NamedLock
public class ReadWriteLockNamedLock extends NamedLockSupport
Named lock support implementation that is usingReadWriteLock
instances. The adapted lock MUST SUPPORT reentrancy, non re-entrant locks will NOT work. It is the responsibility of an adapting lock, to ensure that above lock requirement stands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ReadWriteLockNamedLock.Step
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.locks.ReadWriteLock
readWriteLock
private java.lang.ThreadLocal<java.util.Deque<ReadWriteLockNamedLock.Step>>
threadSteps
-
Fields inherited from class org.eclipse.aether.named.support.NamedLockSupport
logger
-
-
Constructor Summary
Constructors Constructor Description ReadWriteLockNamedLock(java.lang.String name, NamedLockFactorySupport factory, java.util.concurrent.locks.ReadWriteLock readWriteLock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
lockExclusively(long time, java.util.concurrent.TimeUnit unit)
Tries to lock exclusively, may block for given time.boolean
lockShared(long time, java.util.concurrent.TimeUnit unit)
Tries to lock shared, may block for given time.void
unlock()
Unlocks the lock, must be invoked by caller after one of theNamedLock.lockShared(long, TimeUnit)
orNamedLock.lockExclusively(long, TimeUnit)
.-
Methods inherited from class org.eclipse.aether.named.support.NamedLockSupport
close, name
-
-
-
-
Field Detail
-
threadSteps
private final java.lang.ThreadLocal<java.util.Deque<ReadWriteLockNamedLock.Step>> threadSteps
-
readWriteLock
private final java.util.concurrent.locks.ReadWriteLock readWriteLock
-
-
Constructor Detail
-
ReadWriteLockNamedLock
public ReadWriteLockNamedLock(java.lang.String name, NamedLockFactorySupport factory, java.util.concurrent.locks.ReadWriteLock readWriteLock)
-
-
Method Detail
-
lockShared
public boolean lockShared(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:NamedLock
Tries to lock shared, may block for given time. If successful, returnstrue
.- Throws:
java.lang.InterruptedException
-
lockExclusively
public boolean lockExclusively(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:NamedLock
Tries to lock exclusively, may block for given time. If successful, returnstrue
.- Throws:
java.lang.InterruptedException
-
unlock
public void unlock()
Description copied from interface:NamedLock
Unlocks the lock, must be invoked by caller after one of theNamedLock.lockShared(long, TimeUnit)
orNamedLock.lockExclusively(long, TimeUnit)
.
-
-