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

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.20 by jsr166, Sun Nov 22 18:57:17 2009 UTC vs.
Revision 1.21 by jsr166, Thu Nov 26 15:42:15 2009 UTC

# Line 271 | Line 271 | public class LinkedTransferQueueTest ext
271      public void testTakeFromEmpty() throws InterruptedException {
272          final LinkedTransferQueue q = new LinkedTransferQueue();
273          Thread t = newStartedThread(new CheckedInterruptedRunnable() {
274 <            void realRun() throws InterruptedException {
274 >            public void realRun() throws InterruptedException {
275                  q.take();
276              }});
277          Thread.sleep(SHORT_DELAY_MS);
# Line 348 | Line 348 | public class LinkedTransferQueueTest ext
348      public void testInterruptedTimedPoll() throws InterruptedException {
349          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
350          Thread t = newStartedThread(new CheckedRunnable() {
351 <            void realRun() throws InterruptedException {
351 >            public void realRun() throws InterruptedException {
352                  for (int i = 0; i < SIZE; ++i) {
353                      long t0 = System.nanoTime();
354                      threadAssertEquals(i, (int) q.poll(LONG_DELAY_MS,
# Line 375 | Line 375 | public class LinkedTransferQueueTest ext
375      public void testTimedPollWithOffer() throws InterruptedException {
376          final LinkedTransferQueue q = new LinkedTransferQueue();
377          Thread t = new Thread(new CheckedRunnable() {
378 <            void realRun() throws InterruptedException {
378 >            public void realRun() throws InterruptedException {
379                  assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
380                  assertSame(zero, q.poll(LONG_DELAY_MS, MILLISECONDS));
381                  try {
# Line 674 | Line 674 | public class LinkedTransferQueueTest ext
674          ExecutorService executor = Executors.newFixedThreadPool(2);
675  
676          executor.execute(new CheckedRunnable() {
677 <            void realRun() {
677 >            public void realRun() {
678                  threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS,
679                                           MILLISECONDS));
680              }});
681  
682          executor.execute(new CheckedRunnable() {
683 <            void realRun() throws InterruptedException {
683 >            public void realRun() throws InterruptedException {
684                  Thread.sleep(SMALL_DELAY_MS);
685                  threadAssertEquals(one, q.take());
686              }});
# Line 696 | Line 696 | public class LinkedTransferQueueTest ext
696          ExecutorService executor = Executors.newFixedThreadPool(2);
697  
698          executor.execute(new CheckedRunnable() {
699 <            void realRun() throws InterruptedException {
699 >            public void realRun() throws InterruptedException {
700                  threadAssertNull(q.poll());
701                  threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS,
702                                                  MILLISECONDS));
# Line 704 | Line 704 | public class LinkedTransferQueueTest ext
704              }});
705  
706          executor.execute(new CheckedRunnable() {
707 <            void realRun() throws InterruptedException {
707 >            public void realRun() throws InterruptedException {
708                  Thread.sleep(SMALL_DELAY_MS);
709                  q.put(one);
710              }});
# Line 790 | Line 790 | public class LinkedTransferQueueTest ext
790      public void testDrainToWithActivePut() throws InterruptedException {
791          final LinkedTransferQueue q = populatedQueue(SIZE);
792          Thread t = newStartedThread(new CheckedRunnable() {
793 <            void realRun() {
793 >            public void realRun() {
794                  q.put(SIZE + 1);
795              }});
796          ArrayList l = new ArrayList();
# Line 857 | Line 857 | public class LinkedTransferQueueTest ext
857          assertFalse(q.hasWaitingConsumer());
858  
859          Thread t = newStartedThread(new CheckedRunnable() {
860 <            void realRun() throws InterruptedException {
860 >            public void realRun() throws InterruptedException {
861                  Thread.sleep(SMALL_DELAY_MS);
862                  threadAssertTrue(q.hasWaitingConsumer());
863                  threadAssertEquals(q.getWaitingConsumerCount(), 1);
# Line 892 | Line 892 | public class LinkedTransferQueueTest ext
892              = new LinkedTransferQueue<Integer>();
893  
894          Thread t = newStartedThread(new CheckedRunnable() {
895 <            void realRun() throws InterruptedException {
895 >            public void realRun() throws InterruptedException {
896                  q.transfer(SIZE);
897                  threadAssertTrue(q.isEmpty());
898              }});
# Line 912 | Line 912 | public class LinkedTransferQueueTest ext
912              = new LinkedTransferQueue<Integer>();
913  
914          Thread first = newStartedThread(new CheckedRunnable() {
915 <            void realRun() throws InterruptedException {
915 >            public void realRun() throws InterruptedException {
916                  Integer i = SIZE + 1;
917                  q.transfer(i);
918                  threadAssertTrue(!q.contains(i));
# Line 921 | Line 921 | public class LinkedTransferQueueTest ext
921  
922          Thread interruptedThread = newStartedThread(
923              new CheckedInterruptedRunnable() {
924 <                void realRun() throws InterruptedException {
924 >                public void realRun() throws InterruptedException {
925                      while (q.size() == 0)
926                          Thread.yield();
927                      q.transfer(SIZE);
# Line 947 | Line 947 | public class LinkedTransferQueueTest ext
947          final LinkedTransferQueue q = new LinkedTransferQueue();
948  
949          Thread t = newStartedThread(new CheckedRunnable() {
950 <            void realRun() throws InterruptedException {
950 >            public void realRun() throws InterruptedException {
951                  q.transfer(four);
952                  threadAssertFalse(q.contains(four));
953                  threadAssertEquals(three, q.poll());
# Line 968 | Line 968 | public class LinkedTransferQueueTest ext
968              = new LinkedTransferQueue<Integer>();
969  
970          Thread t = newStartedThread(new CheckedRunnable() {
971 <            void realRun() throws InterruptedException {
971 >            public void realRun() throws InterruptedException {
972                  q.transfer(SIZE);
973                  checkEmpty(q);
974              }});
# Line 1010 | Line 1010 | public class LinkedTransferQueueTest ext
1010          final LinkedTransferQueue q = new LinkedTransferQueue();
1011  
1012          Thread t = newStartedThread(new CheckedRunnable() {
1013 <            void realRun() {
1013 >            public void realRun() {
1014                  while (! q.hasWaitingConsumer())
1015                      Thread.yield();
1016                  threadAssertTrue(q.hasWaitingConsumer());
# Line 1033 | Line 1033 | public class LinkedTransferQueueTest ext
1033          final LinkedTransferQueue q = new LinkedTransferQueue();
1034  
1035          Thread t = newStartedThread(new CheckedRunnable() {
1036 <            void realRun() {
1036 >            public void realRun() {
1037                  while (! q.hasWaitingConsumer())
1038                      Thread.yield();
1039                  threadAssertTrue(q.hasWaitingConsumer());
# Line 1055 | Line 1055 | public class LinkedTransferQueueTest ext
1055          final LinkedTransferQueue q = new LinkedTransferQueue();
1056  
1057          Thread toInterrupt = newStartedThread(new CheckedInterruptedRunnable() {
1058 <            void realRun() throws InterruptedException {
1058 >            public void realRun() throws InterruptedException {
1059                  q.tryTransfer(new Object(), LONG_DELAY_MS, MILLISECONDS);
1060              }});
1061  
# Line 1071 | Line 1071 | public class LinkedTransferQueueTest ext
1071          final LinkedTransferQueue q = new LinkedTransferQueue();
1072  
1073          Thread t = newStartedThread(new CheckedRunnable() {
1074 <            void realRun() throws InterruptedException {
1074 >            public void realRun() throws InterruptedException {
1075                  threadAssertFalse
1076                      (q.tryTransfer(new Object(),
1077                                     SHORT_DELAY_MS, MILLISECONDS));
# Line 1091 | Line 1091 | public class LinkedTransferQueueTest ext
1091          assertTrue(q.offer(four));
1092  
1093          Thread t = newStartedThread(new CheckedRunnable() {
1094 <            void realRun() throws InterruptedException {
1094 >            public void realRun() throws InterruptedException {
1095                  threadAssertTrue(q.tryTransfer(five,
1096                                                 MEDIUM_DELAY_MS, MILLISECONDS));
1097                  threadAssertTrue(q.isEmpty());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines