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:
AutoCloseable
,NamedLock
Named lock support implementation that is using "adapted" semaphore (to be able to use semaphores not sharing common
API).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Wrapper 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
ConstructorDescriptionAdaptedSemaphoreNamedLock
(String name, NamedLockFactorySupport factory, AdaptedSemaphoreNamedLock.AdaptedSemaphore semaphore) -
Method Summary
Modifier and TypeMethodDescriptionboolean
lockExclusively
(long time, TimeUnit unit) Tries to lock exclusively, may block for given time.boolean
lockShared
(long time, 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 Details
-
AdaptedSemaphoreNamedLock
public AdaptedSemaphoreNamedLock(String name, NamedLockFactorySupport factory, AdaptedSemaphoreNamedLock.AdaptedSemaphore semaphore)
-
-
Method Details
-
lockExclusively
Description copied from interface:NamedLock
Tries to lock exclusively, may block for given time. If successful, returnstrue
.- Throws:
InterruptedException
-
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)
.