Skip to content

Commit

Permalink
Process pending transactions batches, reducing the number of latch ac…
Browse files Browse the repository at this point in the history
…quisitions.
  • Loading branch information
broneill committed Oct 18, 2024
1 parent 165de50 commit 440a7d3
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,17 @@ void interrupt() {
public void run() {
while (true) {
int awaitResult = 1; // signaled
PendingTxn pending;

PendingTxn first, last;

acquireExclusive();
try {
while (true) {
pending = mFirst;
if (pending != null) {
if (pending == mLast) {
mFirst = null;
mLast = null;
} else {
mFirst = pending.getNextPlain();
}
first = mFirst;
if (first != null) {
last = mLast;
mFirst = null;
mLast = null;
break;
}

Expand All @@ -106,7 +105,18 @@ public void run() {
releaseExclusive();
}

pending.run();
while (true) {
try {
first.run();
} catch (Throwable e) {
// PendingTxn should catch and report any exceptions, but just in case
// something leaks out, ignore it and move on.
}
if (first == last) {
break;
}
first = first.getNextPlain();
}
}
}
}

0 comments on commit 440a7d3

Please sign in to comment.