本文整理匯總了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();
}