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.
-
-
Field Summary
-
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
-
-
-
-
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)
.
-
-