FileDocCategorySizeDatePackage
LockManager.javaAPI DocAndroid 1.5 API2884Wed May 06 22:41:04 BST 2009org.apache.harmony.nio.internal

LockManager

public final class LockManager extends Object
The lock manager is responsible for tracking acquired and pending locks on the underlying file channel.

Fields Summary
private final Comparator
lockComparator
private final SortedSet
locks
Constructors Summary
protected LockManager()


    /*
     * Default Constructor.
     */
      
        super();
    
Methods Summary
synchronized voidaddLock(java.nio.channels.FileLock lock)

        long lockEnd = lock.position() + lock.size();
        for (Iterator<FileLock> keyItr = locks.iterator(); keyItr.hasNext();) {
            FileLock existingLock = keyItr.next();
            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);
    
synchronized voidremoveLock(java.nio.channels.FileLock lock)

        locks.remove(lock);