ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/TimeoutProducerConsumerLoops.java
(Generate patch)

Comparing jsr166/src/test/loops/TimeoutProducerConsumerLoops.java (file contents):
Revision 1.6 by jsr166, Mon Nov 16 04:16:43 2009 UTC vs.
Revision 1.15 by jsr166, Sat Dec 31 21:34:47 2016 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import java.util.concurrent.*;
8 <
7 > import java.util.concurrent.ArrayBlockingQueue;
8 > import java.util.concurrent.CyclicBarrier;
9 > import java.util.concurrent.BlockingQueue;
10 > import java.util.concurrent.ExecutorService;
11 > import java.util.concurrent.Executors;
12 > import java.util.concurrent.LinkedBlockingDeque;
13 > import java.util.concurrent.LinkedBlockingQueue;
14 > import java.util.concurrent.LinkedTransferQueue;
15 > import java.util.concurrent.Phaser;
16 > import java.util.concurrent.PriorityBlockingQueue;
17 > import java.util.concurrent.SynchronousQueue;
18 > import java.util.concurrent.TimeUnit;
19  
20   public class TimeoutProducerConsumerLoops {
21      static final int NCPUS = Runtime.getRuntime().availableProcessors();
# Line 51 | Line 61 | public class TimeoutProducerConsumerLoop
61              maxPairs = Integer.parseInt(args[0]);
62  
63          print = true;
64 <        int k = 1;
55 <        for (int i = 1; i <= maxPairs;) {
64 >        for (int k = 1, i = 1; i <= maxPairs;) {
65              System.out.println("Pairs:" + i);
66              oneTest(i, iters);
67              Thread.sleep(100);
# Line 64 | Line 73 | public class TimeoutProducerConsumerLoop
73                  i = k;
74          }
75          pool.shutdown();
76 <   }
76 >    }
77  
78      static void oneTest(int n, int iters) throws Exception {
79          if (print)
# Line 106 | Line 115 | public class TimeoutProducerConsumerLoop
115          if (print)
116              System.out.print("ArrayBlockingQueue(fair) ");
117          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, iters/16);
109
118      }
119  
120 <    static abstract class Stage implements Runnable {
120 >    abstract static class Stage implements Runnable {
121          final int iters;
122          final BlockingQueue<Integer> queue;
123          final CyclicBarrier barrier;
124          final Phaser lagPhaser;
125 <        Stage (BlockingQueue<Integer> q, CyclicBarrier b, Phaser s, int iters) {
125 >        Stage(BlockingQueue<Integer> q, CyclicBarrier b, Phaser s, int iters) {
126              queue = q;
127              barrier = b;
128              lagPhaser = s;
# Line 216 | Line 224 | public class TimeoutProducerConsumerLoop
224      static final class LTQasSQ<T> extends LinkedTransferQueue<T> {
225          LTQasSQ() { super(); }
226          public void put(T x) {
227 <            try { super.transfer(x);
228 <            } catch (InterruptedException ex) { throw new Error(); }
227 >            try { super.transfer(x); }
228 >            catch (InterruptedException ex) { throw new Error(ex); }
229          }
230  
231          public boolean offer(T x, long timeout, TimeUnit unit) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines