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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations