use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project aries by apache.
the class RWLock method runWriteOperation.
public void runWriteOperation(Runnable r) {
WriteLock wl = _lock.writeLock();
wl.lock();
try {
r.run();
} finally {
wl.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project aries by apache.
the class RWLock method runWriteOperation.
public <T> T runWriteOperation(Callable<T> call) throws Exception {
WriteLock wl = _lock.writeLock();
wl.lock();
try {
return call.call();
} finally {
wl.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method loadVisibleModel.
private void loadVisibleModel(final E object, final List<ExpandingTableNode<E>> model) {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
if (isVisible(object)) {
ExpandingTableNode<E> node = getNode(object);
// protect against a null node if the model does not contain a requested visible object
if (node != null) {
model.add(node);
}
if (isParent(object)) {
for (E child : getChildren(object)) {
loadVisibleModel(child, model);
}
}
}
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method addNode.
protected void addNode(final E object) {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
objects.put(object, new ExpandingTableNode<>(object));
keys.add(object);
buildVisibleModel();
fireTableDataChanged();
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method buildVisibleModel.
private synchronized void buildVisibleModel(final E root) {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
List<ExpandingTableNode<E>> model = new ArrayList<>();
for (E child : getChildren(root)) {
loadVisibleModel(child, model);
}
visibleObjects = model;
} finally {
writeLock.unlock();
}
}
Aggregations