Package org.eclipse.aether.named.support
Class FileLockNamedLock
- java.lang.Object
-
- org.eclipse.aether.named.support.NamedLockSupport
-
- org.eclipse.aether.named.support.FileLockNamedLock
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,NamedLock
public final class FileLockNamedLock extends NamedLockSupport
Named lock that usesFileLock
. An instance of this class is about ONE LOCK (one file) and is possibly used by multiple threads. Each thread (if properly coded re boxing) will try to obtain either shared or exclusive lock. As file locks are JVM-scoped (so one JVM can obtain same file lock only once), the threads share file lock and synchronize according to it. Still, as file lock obtain operation does not block (or in other words, the method that does block cannot be controlled for how long it blocks), we are "simulating" thread blocking usingRetry
utility. This implementation performs coordination not only on thread (JVM-local) level, but also on process level, as long as other parties are using this same "advisory" locking mechanism.- Since:
- 1.7.3
-
-
Field Summary
-
Fields inherited from class org.eclipse.aether.named.support.NamedLockSupport
logger
-
-
Constructor Summary
Constructors Constructor Description FileLockNamedLock(java.lang.String name, java.nio.channels.FileChannel fileChannel, NamedLockFactorySupport factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
doLockExclusively(long time, java.util.concurrent.TimeUnit unit)
protected boolean
doLockShared(long time, java.util.concurrent.TimeUnit unit)
protected void
doUnlock()
-
Methods inherited from class org.eclipse.aether.named.support.NamedLockSupport
close, diagnosticState, doClose, lockExclusively, lockShared, name, toString, unlock
-
-
-
-
Constructor Detail
-
FileLockNamedLock
public FileLockNamedLock(java.lang.String name, java.nio.channels.FileChannel fileChannel, NamedLockFactorySupport factory)
-
-
Method Detail
-
doLockShared
protected boolean doLockShared(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
doLockShared
in classNamedLockSupport
- Throws:
java.lang.InterruptedException
-
doLockExclusively
protected boolean doLockExclusively(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
doLockExclusively
in classNamedLockSupport
- Throws:
java.lang.InterruptedException
-
doUnlock
protected void doUnlock()
- Specified by:
doUnlock
in classNamedLockSupport
-
-