use of org.janusgraph.graphdb.transaction.lock.ReentrantTransactionLock in project janusgraph by JanusGraph.
the class StandardJanusGraphTx method getLock.
private TransactionLock getLock(final LockTuple la) {
if (config.isSingleThreaded())
return FakeLock.INSTANCE;
Map<LockTuple, TransactionLock> result = uniqueLocks;
if (result == UNINITIALIZED_LOCKS) {
Preconditions.checkArgument(!config.isSingleThreaded());
synchronized (this) {
result = uniqueLocks;
if (result == UNINITIALIZED_LOCKS)
uniqueLocks = result = new ConcurrentHashMap<>();
}
}
// TODO: clean out no longer used locks from uniqueLocks when it grows to large (use ReadWriteLock to protect against race conditions)
TransactionLock lock = new ReentrantTransactionLock();
TransactionLock existingLock = result.putIfAbsent(la, lock);
return (existingLock == null) ? lock : existingLock;
}
Aggregations