本文整理汇总了Java中java.nio.channels.FileLock.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java FileLock.isValid方法的具体用法?Java FileLock.isValid怎么用?Java FileLock.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.channels.FileLock
的用法示例。
在下文中一共展示了FileLock.isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: implCloseChannel
import java.nio.channels.FileLock; //导入方法依赖的package包/类
protected void implCloseChannel() throws IOException {
// Release and invalidate any locks that we still hold
if (fileLockTable != null) {
for (FileLock fl: fileLockTable.removeAll()) {
synchronized (fl) {
if (fl.isValid()) {
nd.release(fd, fl.position(), fl.size());
((FileLockImpl)fl).invalidate();
}
}
}
}
// signal any threads blocked on this channel
threads.signalAndWait();
if (parent != null) {
// Close the fd via the parent stream's close method. The parent
// will reinvoke our close method, which is defined in the
// superclass AbstractInterruptibleChannel, but the isOpen logic in
// that method will prevent this method from being reinvoked.
//
((java.io.Closeable)parent).close();
} else {
nd.close(fd);
}
}
示例2: closeLockFile
import java.nio.channels.FileLock; //导入方法依赖的package包/类
void closeLockFile() {
FileLock myfl = this.fl;
if (myfl != null) {
try {
FileChannel fc = myfl.channel();
if (myfl.isValid()) {
myfl.release();
}
fc.close();
} catch (IOException ignore) {
}
this.fl = null;
}
File f = this.lockFile;
if (f != null) {
if (f.delete()) {
if (logger.isDebugEnabled()) {
logger.debug("Deleted lock file {}", f);
}
} else if (f.exists()) {
if (logger.isDebugEnabled()) {
logger.debug("Could not delete lock file {}", f);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Unlocked disk store {}", name);
}
}
示例3: implCloseChannel
import java.nio.channels.FileLock; //导入方法依赖的package包/类
protected void implCloseChannel() throws IOException {
if (!fd.valid())
return; // nothing to do
// Release and invalidate any locks that we still hold
if (fileLockTable != null) {
for (FileLock fl: fileLockTable.removeAll()) {
synchronized (fl) {
if (fl.isValid()) {
nd.release(fd, fl.position(), fl.size());
((FileLockImpl)fl).invalidate();
}
}
}
}
// signal any threads blocked on this channel
threads.signalAndWait();
if (parent != null) {
// Close the fd via the parent stream's close method. The parent
// will reinvoke our close method, which is defined in the
// superclass AbstractInterruptibleChannel, but the isOpen logic in
// that method will prevent this method from being reinvoked.
//
((java.io.Closeable)parent).close();
} else {
nd.close(fd);
}
}
示例4: isValid
import java.nio.channels.FileLock; //导入方法依赖的package包/类
private static boolean isValid(FileLock fileLock) {
return fileLock != null && fileLock.isValid();
}