Commit c22f11b5 authored by Ivo Anjo's avatar Ivo Anjo

Minor API cleanups

AtomicRunnable.warmup() should be used instead of Warmup.doWarmup(AtomicRunnable).
Add private empty constructors and final modifers to static-only classes.
parent eb61c5cd
......@@ -34,7 +34,7 @@ public final class Test3 {
}
};
Warmup.doWarmup(transaction);
transaction.warmup();
x = 0;
y = 0;
......
......@@ -47,7 +47,7 @@ public final class Test6 {
}
};
Warmup.doWarmup(transaction);
transaction.warmup();
Thread[] threads = new Thread[Runtime.getRuntime().availableProcessors()];
......
......@@ -36,6 +36,8 @@ public final class TransactionStats {
private static final int[] STATS_COUNT = new int[TX_RETURN_CODES.length];
private TransactionStats() { }
public static void registerResult(int status) {
for (int i = 0; i < TX_RETURN_CODES.length; i++) {
if (status == (Integer) TX_RETURN_CODES[i][0]) {
......
......@@ -23,7 +23,7 @@ package javartm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Warmup {
public final class Warmup {
private static final Logger Log = LoggerFactory.getLogger(Warmup.class);
// Default JIT compiler threshold for current hotspot versions
......@@ -33,6 +33,8 @@ public class Warmup {
// In some cases, the value above is not enough, so let's arbitrarily do a bit more
private static final int ITERATIONS = HOTSPOT_JIT_THRESHOLD * 3;
private Warmup() { }
/** Warms up the received runnable by calling it repeatedly until the VM JIT kicks in **/
public static void doWarmup(Runnable r) {
for (int i = 0; i < ITERATIONS; i++) r.run();
......@@ -43,7 +45,7 @@ public class Warmup {
}
/** Warms up the received runnable by calling it repeatedly until the VM JIT kicks in **/
public static void doWarmup(AtomicRunnable<?> r) {
protected static void doWarmup(AtomicRunnable<?> r) {
r.beforeWarmup();
for (int i = 0; i < ITERATIONS; i++) {
r.beforeWarmupIteration();
......
......@@ -22,7 +22,6 @@ package javartm.tests.rtm;
import javartm.AtomicRunnable;
import javartm.Transaction;
import javartm.Warmup;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -68,7 +67,7 @@ public class TransactionTest1 {
return true;
}
};
Warmup.doWarmup(transaction);
transaction.warmup();
Boolean result = Transaction.doTransactionally(transaction);
Assert.assertTrue(result);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment