Package org.eclipse.aether.named.support
Class AdaptedSemaphoreNamedLock
- java.lang.Object
-
- org.eclipse.aether.named.support.NamedLockSupport
-
- org.eclipse.aether.named.support.AdaptedSemaphoreNamedLock
-
- All Implemented Interfaces:
java.lang.AutoCloseable,NamedLock
public class AdaptedSemaphoreNamedLock extends NamedLockSupport
Named lock support implementation that is using "adapted" semaphore (to be able to use semaphores not sharing common API).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAdaptedSemaphoreNamedLock.AdaptedSemaphoreWrapper for semaphore-like stuff, that do not share common ancestor.
-
Field Summary
-
Fields inherited from class org.eclipse.aether.named.support.NamedLockSupport
logger
-
-
Constructor Summary
Constructors Constructor Description AdaptedSemaphoreNamedLock(java.lang.String name, NamedLockFactorySupport factory, AdaptedSemaphoreNamedLock.AdaptedSemaphore semaphore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanlockExclusively(long time, java.util.concurrent.TimeUnit unit)Tries to lock exclusively, may block for given time.booleanlockShared(long time, java.util.concurrent.TimeUnit unit)Tries to lock shared, may block for given time.voidunlock()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
-
AdaptedSemaphoreNamedLock
public AdaptedSemaphoreNamedLock(java.lang.String name, NamedLockFactorySupport factory, AdaptedSemaphoreNamedLock.AdaptedSemaphore semaphore)
-
-
Method Detail
-
lockShared
public boolean lockShared(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from interface:NamedLockTries 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:NamedLockTries to lock exclusively, may block for given time. If successful, returnstrue.- Throws:
java.lang.InterruptedException
-
unlock
public void unlock()
Description copied from interface:NamedLockUnlocks the lock, must be invoked by caller after one of theNamedLock.lockShared(long, TimeUnit)orNamedLock.lockExclusively(long, TimeUnit).
-
-