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

Comparing jsr166/src/test/loops/SingleProducerMultipleConsumerLoops.java (file contents):
Revision 1.6 by jsr166, Mon Sep 27 19:15:16 2010 UTC vs.
Revision 1.12 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 < //import jsr166y.*;
7 > import java.util.concurrent.ArrayBlockingQueue;
8 > import java.util.concurrent.BlockingQueue;
9 > import java.util.concurrent.CyclicBarrier;
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.PriorityBlockingQueue;
16 > import java.util.concurrent.SynchronousQueue;
17  
18   public class SingleProducerMultipleConsumerLoops {
19      static final int NCPUS = Runtime.getRuntime().availableProcessors();
# Line 36 | Line 44 | public class SingleProducerMultipleConsu
44          warmup();
45          print = true;
46  
47 <        int k = 1;
40 <        for (int i = 1; i <= maxn;) {
47 >        for (int k = 1, i = 1; i <= maxn;) {
48              System.out.println("Consumers:" + i);
49              oneTest(i, ITERS);
50              if (i == k) {
# Line 49 | Line 56 | public class SingleProducerMultipleConsu
56          }
57  
58          pool.shutdown();
59 <   }
59 >    }
60  
61      static void warmup() throws Exception {
62          print = false;
# Line 128 | Line 135 | public class SingleProducerMultipleConsu
135          if (print)
136              System.out.print("ArrayBlockingQueue(fair)");
137          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, fairIters);
131
138      }
139  
140      abstract static class Stage implements Runnable {
# Line 170 | Line 176 | public class SingleProducerMultipleConsu
176      static class Consumer extends Stage {
177          Consumer(BlockingQueue<Integer> q, CyclicBarrier b, int iters) {
178              super(q, b, iters);
173
179          }
180  
181          public void run() {
# Line 211 | Line 216 | public class SingleProducerMultipleConsu
216      static final class LTQasSQ<T> extends LinkedTransferQueue<T> {
217          LTQasSQ() { super(); }
218          public void put(T x) {
219 <            try { super.transfer(x);
220 <            } catch (InterruptedException ex) { throw new Error(); }
219 >            try { super.transfer(x); }
220 >            catch (InterruptedException ex) { throw new Error(ex); }
221          }
222      }
223  
# Line 223 | Line 228 | public class SingleProducerMultipleConsu
228              if ((++calls & 1) == 0)
229                  super.put(x);
230              else {
231 <                try { super.transfer(x);
232 <                } catch (InterruptedException ex) {
228 <                    throw new Error();
229 <                }
231 >                try { super.transfer(x); }
232 >                catch (InterruptedException ex) { throw new Error(ex); }
233              }
234          }
235      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines