本文整理了Java中java.nio.channels.FileLock.position()
方法的一些代码示例,展示了FileLock.position()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileLock.position()
方法的具体详情如下:
包路径:java.nio.channels.FileLock
类名称:FileLock
方法名:position
[英]Returns the lock's starting position in the file.
[中]返回文件中锁的起始位置。
代码示例来源:origin: robovm/robovm
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: com.h2database/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: robovm/robovm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: robovm/robovm
/**
* Non-API method to release a given lock on a file channel. Assumes that
* the lock will mark itself invalid after successful unlocking.
*/
public void release(FileLock lock) throws IOException {
checkOpen();
StructFlock flock = new StructFlock();
flock.l_type = (short) F_UNLCK;
flock.l_whence = (short) SEEK_SET;
flock.l_start = lock.position();
flock.l_len = translateLockLength(lock.size());
try {
Libcore.os.fcntlFlock(fd, F_SETLKW64, flock);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsIOException();
}
removeLock(lock);
}
代码示例来源:origin: com.bugvm/bugvm-rt
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: ibinti/bugvm
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: MobiVM/robovm
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: com.gluonhq/robovm-rt
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: FlexoVM/flexovm
public int compare(FileLock lock1, FileLock lock2) {
long position1 = lock1.position();
long position2 = lock2.position();
return position1 > position2 ? 1 : (position1 < position2 ? -1 : 0);
}
};
代码示例来源:origin: MobiVM/robovm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: ibinti/bugvm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: org.wowtools/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: com.eventsourcing/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: org.apache.sshd/sshd-sftp
public void unlock(long offset, long length) throws IOException {
SeekableByteChannel channel = getFileChannel();
long size = (length == 0L) ? channel.size() - offset : length;
FileLock lock = null;
for (Iterator<FileLock> iterator = locks.iterator(); iterator.hasNext();) {
FileLock l = iterator.next();
if ((l.position() == offset) && (l.size() == size)) {
iterator.remove();
lock = l;
break;
}
}
if (lock == null) {
throw new SftpException(SftpConstants.SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK,
"No matching lock found on range [" + offset + "-" + (offset + length));
}
lock.release();
}
代码示例来源:origin: org.tmatesoft.sqljet/sqljet
/**
* @param channel
* @param position
* @param size
* @param shared
*/
public SqlJetFileLock(SqlJetFileLockManager manager, FileLock fileLock) {
super(fileLock.channel(), fileLock.position(), fileLock.size(), fileLock.isShared());
this.manager = manager;
this.fileLock = fileLock;
this.locksCount = 1;
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Non-API method to release a given lock on a file channel. Assumes that
* the lock will mark itself invalid after successful unlocking.
*/
public void release(FileLock lock) throws IOException {
checkOpen();
StructFlock flock = new StructFlock();
flock.l_type = (short) F_UNLCK;
flock.l_whence = (short) SEEK_SET;
flock.l_start = lock.position();
flock.l_len = translateLockLength(lock.size());
try {
Libcore.os.fcntlFlock(fd, F_SETLKW64, flock);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsIOException();
}
removeLock(lock);
}
代码示例来源:origin: MobiVM/robovm
/**
* Non-API method to release a given lock on a file channel. Assumes that
* the lock will mark itself invalid after successful unlocking.
*/
public void release(FileLock lock) throws IOException {
checkOpen();
StructFlock flock = new StructFlock();
flock.l_type = (short) F_UNLCK;
flock.l_whence = (short) SEEK_SET;
flock.l_start = lock.position();
flock.l_len = translateLockLength(lock.size());
try {
Libcore.os.fcntlFlock(fd, F_SETLKW64, flock);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsIOException();
}
removeLock(lock);
}
内容来源于网络,如有侵权,请联系作者删除!