use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method toggleExpansion.
public void toggleExpansion(final E object) {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
if (isParent(object)) {
ExpandingTableNode<E> node = getNode(object);
node.setExpanded(!node.isExpanded());
preferences.put(EXPANSION_STATE, getExpansionState());
fireNodeChanged();
}
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method clear.
protected void clear() {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
visibleObjects.clear();
objects.clear();
keys.clear();
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.
the class AbstractExpandingTableModel method loadModel.
private void loadModel() {
WriteLock writeLock = rwl.writeLock();
writeLock.lock();
try {
keys.clear();
objects.clear();
visibleObjects.clear();
for (E object : getModelObjects()) {
objects.put(object, new ExpandingTableNode<>(object));
keys.add(object);
}
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project zookeeper by apache.
the class ZKDatabase method addCommittedProposal.
/**
* maintains a list of last <i>committedLog</i>
* or so committed requests. This is used for
* fast follower synchronization.
* @param request committed request
*/
public void addCommittedProposal(Request request) {
WriteLock wl = logLock.writeLock();
try {
wl.lock();
if (committedLog.size() > commitLogCount) {
committedLog.removeFirst();
minCommittedLog = committedLog.getFirst().packet.getZxid();
}
if (committedLog.isEmpty()) {
minCommittedLog = request.zxid;
maxCommittedLog = request.zxid;
}
byte[] data = SerializeUtils.serializeRequest(request);
QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid, data, null);
Proposal p = new Proposal();
p.packet = pp;
p.request = request;
committedLog.add(p);
maxCommittedLog = p.packet.getZxid();
} 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();
}
}
Aggregations