"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dso-l1/src/main/java/com/tc/object/TransactionSource.java" between
terracotta-core-5.7.0.tar.gz and terracotta-core-5.7.1.tar.gz

About: Terracotta - Clustering technology for Java ("Network Attached Memory", "Distributed Cache"). Source code of the server (5.x) core components.

TransactionSource.java  (terracotta-core-5.7.0):TransactionSource.java  (terracotta-core-5.7.1)
skipping to change at line 22 skipping to change at line 22
* *
* The Covered Software is Terracotta Core. * The Covered Software is Terracotta Core.
* *
* The Initial Developer of the Covered Software is * The Initial Developer of the Covered Software is
* Terracotta, Inc., a Software AG company * Terracotta, Inc., a Software AG company
* *
*/ */
package com.tc.object; package com.tc.object;
import com.tc.object.tx.TransactionID; import com.tc.object.tx.TransactionID;
import java.util.BitSet;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
public class TransactionSource { public class TransactionSource {
private static final AtomicLong nextTransactionId = new AtomicLong(1L); private final AtomicLong current = new AtomicLong();
private volatile TransactionID oldestCache = TransactionID.FIRST_ID;
private static final ConcurrentSkipListSet<Long> pending = new ConcurrentSkipL private long retiredBase = 1L;
istSet<>(); private int retirePosition = 0;
private final long GC_THRESHOLD = 32 * 1024;
private BitSet retired = new BitSet();
public TransactionID create() { public TransactionID create() {
long txn; return new TransactionID(current.incrementAndGet());
while (!pending.add((txn = nextTransactionId.getAndIncrement())));
return new TransactionID(txn);
} }
public TransactionID oldest() { public TransactionID oldest() {
Long first = pending.first(); return oldestCache;
if (first == null) { }
return null;
} else { private void updateOldest() {
return new TransactionID(first); retirePosition = retired.nextClearBit(retirePosition);
long transactionId = retirePosition + retiredBase;
if (oldestCache.toLong() != transactionId) {
oldestCache = new TransactionID(transactionId);
}
}
private void gc() {
if (retirePosition > GC_THRESHOLD) {
retiredBase += retirePosition;
retired = retired.get(retirePosition, retired.size());
retirePosition = 0;
} }
} }
public boolean retire(TransactionID txnId) { public synchronized boolean retire(TransactionID txnId) {
return pending.remove(txnId.toLong()); int index = (int)(txnId.toLong() - retiredBase);
boolean last = !retired.get(index);
retired.set(index);
updateOldest();
gc();
return last;
} }
} }
 End of changes. 5 change blocks. 
16 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)