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.27 by jsr166, Thu Oct 28 17:22:13 2010 UTC vs.
Revision 1.28 by jsr166, Thu Oct 28 17:57:26 2010 UTC

# Line 274 | Line 274 | public class LinkedTransferQueueTest ext
274      }
275  
276      /**
277 <     * take blocks interruptibly when empty
278 <     */
279 <    public void testTakeFromEmpty() throws InterruptedException {
280 <        final LinkedTransferQueue q = new LinkedTransferQueue();
281 <        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
282 <            public void realRun() throws InterruptedException {
283 <                q.take();
284 <            }});
285 <        Thread.sleep(SHORT_DELAY_MS);
286 <        t.interrupt();
287 <        t.join();
288 <    }
289 <
290 <    /**
291 <     * Take removes existing elements until empty, then blocks interruptibly
277 >     * take removes existing elements until empty, then blocks interruptibly
278       */
279      public void testBlockingTake() throws InterruptedException {
280          final LinkedTransferQueue<Integer> q = populatedQueue(SIZE);
# Line 342 | Line 328 | public class LinkedTransferQueueTest ext
328          for (int i = 0; i < SIZE; ++i) {
329              long t0 = System.nanoTime();
330              assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
331 <            long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024);
346 <            assertTrue(millisElapsed < SMALL_DELAY_MS);
331 >            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
332          }
333          assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS));
334          checkEmpty(q);
# Line 360 | Line 345 | public class LinkedTransferQueueTest ext
345                  for (int i = 0; i < SIZE; ++i) {
346                      long t0 = System.nanoTime();
347                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
348 <                    long millisElapsed = (System.nanoTime() - t0)/(1024 * 1024);
364 <                    assertTrue(millisElapsed < SMALL_DELAY_MS);
348 >                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
349                  }
350                  try {
351                      q.poll(LONG_DELAY_MS, MILLISECONDS);
# Line 1057 | Line 1041 | public class LinkedTransferQueueTest ext
1041                  long t0 = System.nanoTime();
1042                  assertFalse(q.tryTransfer(new Object(),
1043                                            SHORT_DELAY_MS, MILLISECONDS));
1044 <                long elapsed = NANOSECONDS.toMillis(System.nanoTime() - t0);
1061 <                assertTrue(elapsed >= SHORT_DELAY_MS);
1044 >                assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);
1045              }});
1046  
1047          checkEmpty(q);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines