Package org.eclipse.aether.named.support
Class NamedLockSupport
java.lang.Object
org.eclipse.aether.named.support.NamedLockSupport
- All Implemented Interfaces:
AutoCloseable
,NamedLock
- Direct Known Subclasses:
AdaptedSemaphoreNamedLock
,CompositeNamedLock
,FileLockNamedLock
,ReadWriteLockNamedLock
Support class for
NamedLock
implementations providing reference counting.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
Closes the lock resource.Returns the diagnostic state (if collected) or empty map, nevernull
.protected void
doClose()
protected abstract boolean
doLockExclusively
(long time, TimeUnit unit) protected abstract boolean
doLockShared
(long time, TimeUnit unit) protected abstract void
doUnlock()
key()
Returns this instance key, nevernull
.boolean
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.toString()
void
unlock()
Unlocks the lock, must be invoked by caller after one of theNamedLock.lockShared(long, TimeUnit)
orNamedLock.lockExclusively(long, TimeUnit)
.
-
Field Details
-
logger
-
-
Constructor Details
-
NamedLockSupport
-
-
Method Details
-
key
Description copied from interface:NamedLock
Returns this instance key, nevernull
. -
lockExclusively
Description copied from interface:NamedLock
Tries to lock exclusively, may block for given time. If successful, returnstrue
.- Specified by:
lockExclusively
in interfaceNamedLock
- Throws:
InterruptedException
-
doLockExclusively
- 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)
. -
doUnlock
-
close
Description copied from interface:NamedLock
Closes the lock resource. Lock MUST be unlocked usingNamedLock.unlock()
in case any locking happened on it. After invoking this method, the lock instance MUST NOT be used anymore. If lock for same name needed, a new instance should be obtained from factory usingNamedLockFactory.getLock(java.util.Collection)
. Ideally, instances are to be used within try-with-resource blocks, so calling this method directly is not really needed, nor advised.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceNamedLock
-
doClose
-
diagnosticState
Returns the diagnostic state (if collected) or empty map, nevernull
.- Since:
- 1.9.11
-
toString
-