Search in sources :

Example 6 with ReadLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock in project aries by apache.

the class RWLock method runReadOperation.

public <T> T runReadOperation(Callable<T> call) throws Exception {
    ReadLock rl = _lock.readLock();
    rl.lock();
    try {
        return call.call();
    } finally {
        rl.unlock();
    }
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)

Example 7 with ReadLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock in project jgnash by ccavanaugh.

the class AbstractExpandingTableModel method getObjects.

/**
     * Returns a {@code Collection} of objects loaded into the model at the time this method is called.
     *
     * @return {@code Collection} of objects
     */
public Set<E> getObjects() {
    ReadLock readLock = rwl.readLock();
    readLock.lock();
    try {
        // return a defensive copy
        return new HashSet<>(keys);
    } finally {
        readLock.unlock();
    }
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock) HashSet(java.util.HashSet)

Example 8 with ReadLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock in project jgnash by ccavanaugh.

the class AbstractExpandingTableModel method size.

/**
     * Returns the number of visible objects in this model.
     *
     * @return the number of visible objects in this model
     * @see List#size()
     */
private int size() {
    ReadLock readLock = rwl.readLock();
    readLock.lock();
    try {
        return visibleObjects.size();
    } finally {
        readLock.unlock();
    }
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)

Example 9 with ReadLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock in project jgnash by ccavanaugh.

the class AbstractExpandingTableModel method indexOf.

/**
     * Returns the index of the first visible occurrence of the specified element in this model,
     * or -1 if this list does not contain the element.
     *
     * @param object element to search for
     * @return the index of the first visible occurrence of the specified element in this list,
     *         or -1 if this list does not contain the element
     */
public int indexOf(final E object) {
    ReadLock readLock = rwl.readLock();
    readLock.lock();
    try {
        int index = -1;
        for (ExpandingTableNode<E> n : visibleObjects) {
            if (n.getObject().equals(object)) {
                index = visibleObjects.indexOf(n);
                break;
            }
        }
        return index;
    } finally {
        readLock.unlock();
    }
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)

Example 10 with ReadLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock in project jgnash by ccavanaugh.

the class AbstractExpandingTableModel method getNode.

private ExpandingTableNode<E> getNode(final E object) {
    ReadLock readLock = rwl.readLock();
    readLock.lock();
    try {
        return objects.get(object);
    } finally {
        readLock.unlock();
    }
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)

Aggregations

ReadLock (java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)15 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 SnapshotStage (com.torodb.core.transaction.metainf.MetainfoRepository.SnapshotStage)1 Pair (com.zimbra.common.util.Pair)1 FileLogReader (com.zimbra.cs.redolog.logger.FileLogReader)1 Checkpoint (com.zimbra.cs.redolog.op.Checkpoint)1 CommitTxn (com.zimbra.cs.redolog.op.CommitTxn)1 RedoableOp (com.zimbra.cs.redolog.op.RedoableOp)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 NumberFormat (java.text.NumberFormat)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Nonnull (javax.annotation.Nonnull)1 Account (jgnash.engine.Account)1