--- jsr166/src/test/loops/ProducerConsumerLoops.java 2009/10/23 19:57:06 1.3 +++ jsr166/src/test/loops/ProducerConsumerLoops.java 2009/10/29 23:09:08 1.4 @@ -34,14 +34,14 @@ public class ProducerConsumerLoops { static final int POOL_MASK = POOL_SIZE-1; static final Integer[] intPool = new Integer[POOL_SIZE]; static { - for (int i = 0; i < POOL_SIZE; ++i) + for (int i = 0; i < POOL_SIZE; ++i) intPool[i] = Integer.valueOf(i); } // Number of puts by producers or takes by consumers static final int ITERS = 1 << 20; - // max lag between a producer and consumer to avoid + // max lag between a producer and consumer to avoid // this becoming a GC test rather than queue test. // Used only per-pair to lessen impact on queue sync static final int LAG_MASK = (1 << 12) - 1; @@ -49,7 +49,7 @@ public class ProducerConsumerLoops { public static void main(String[] args) throws Exception { int maxPairs = NCPUS * 3 / 2; - if (args.length > 0) + if (args.length > 0) maxPairs = Integer.parseInt(args[0]); warmup(); @@ -61,8 +61,8 @@ public class ProducerConsumerLoops { if (i == k) { k = i << 1; i = i + (i >>> 1); - } - else + } + else i = k; } pool.shutdown(); @@ -73,14 +73,14 @@ public class ProducerConsumerLoops { System.out.print("Warmup "); int it = 2000; for (int j = 5; j > 0; --j) { - oneTest(j, it); + oneTest(j, it); System.out.print("."); it += 1000; } System.gc(); it = 20000; for (int j = 5; j > 0; --j) { - oneTest(j, it); + oneTest(j, it); System.out.print("."); it += 10000; } @@ -110,7 +110,7 @@ public class ProducerConsumerLoops { if (print) System.out.print("LinkedBlockingDeque "); oneRun(new LinkedBlockingDeque(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("ArrayBlockingQueue "); @@ -121,7 +121,7 @@ public class ProducerConsumerLoops { System.out.print("SynchronousQueue "); oneRun(new SynchronousQueue(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("SynchronousQueue(fair) "); @@ -136,7 +136,7 @@ public class ProducerConsumerLoops { if (print) System.out.print("LinkedTransferQueue(half)"); oneRun(new HalfSyncLTQ(), n, iters); - + Thread.sleep(100); // System.gc(); if (print) System.out.print("PriorityBlockingQueue "); @@ -148,7 +148,7 @@ public class ProducerConsumerLoops { oneRun(new ArrayBlockingQueue(POOL_SIZE, true), n, fairIters); } - + static abstract class Stage implements Runnable { final int iters; final BlockingQueue queue; @@ -156,7 +156,7 @@ public class ProducerConsumerLoops { final Phaser lagPhaser; Stage (BlockingQueue q, CyclicBarrier b, Phaser s, int iters) { - queue = q; + queue = q; barrier = b; lagPhaser = s; this.iters = iters; @@ -186,16 +186,16 @@ public class ProducerConsumerLoops { addProducerSum(ps); barrier.await(); } - catch (Exception ie) { - ie.printStackTrace(); - return; + catch (Exception ie) { + ie.printStackTrace(); + return; } } } static class Consumer extends Stage { Consumer(BlockingQueue q, CyclicBarrier b, Phaser s, - int iters) { + int iters) { super(q, b, s, iters); } @@ -213,9 +213,9 @@ public class ProducerConsumerLoops { addConsumerSum(cs); barrier.await(); } - catch (Exception ie) { - ie.printStackTrace(); - return; + catch (Exception ie) { + ie.printStackTrace(); + return; } } @@ -240,7 +240,7 @@ public class ProducerConsumerLoops { static final class LTQasSQ extends LinkedTransferQueue { LTQasSQ() { super(); } public void put(T x) { - try { super.transfer(x); + try { super.transfer(x); } catch (InterruptedException ex) { throw new Error(); } } } @@ -252,9 +252,9 @@ public class ProducerConsumerLoops { if ((++calls & 1) == 0) super.put(x); else { - try { super.transfer(x); - } catch (InterruptedException ex) { - throw new Error(); + try { super.transfer(x); + } catch (InterruptedException ex) { + throw new Error(); } } }