java.util.concurrent.DelayQueue#poll ( )源码实例Demo

下面列出了java.util.concurrent.DelayQueue#poll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pxf   文件: UGICache.java
/**
 * Iterate through all the entries in the queue and close expired {@link UserGroupInformation},
 * otherwise it resets the timer for every non-expired entry.
 *
 * @param expirationQueue
 */
private void cleanup(DelayQueue<Entry> expirationQueue) {

    Entry expiredUGI;
    while ((expiredUGI = expirationQueue.poll()) != null) {
        if (expiredUGI.isNotInUse()) {
            closeUGI(expiredUGI);
        } else {
            // The UGI object is still being used by another thread
            String fsMsg = "FileSystem for proxy user = " + expiredUGI.getSession().getUser();
            LOG.debug("{} Skipping close of {}", expiredUGI.getSession().toString(), fsMsg);
            // Place it back in the queue if still in use and was not closed
            expiredUGI.resetTime();
            expirationQueue.offer(expiredUGI);
        }
        LOG.debug("Delay Queue Size for segment {} = {}", expiredUGI.getSession().getSegmentId(), expirationQueue.size());
    }
}
 
源代码2 项目: openjdk-jdk9   文件: DelayQueueTest.java
/**
 * element returns next element, or throws NSEE if empty
 */
public void testElement() {
    DelayQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(new PDelay(i), q.element());
        q.poll();
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}
 
源代码3 项目: openjdk-jdk9   文件: DelayQueueTest.java
/**
 * contains(x) reports true when elements added but not yet removed
 */
public void testContains() {
    DelayQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.contains(new PDelay(i)));
        q.poll();
        assertFalse(q.contains(new PDelay(i)));
    }
}
 
源代码4 项目: j2objc   文件: DelayQueueTest.java
/**
 * element returns next element, or throws NSEE if empty
 */
public void testElement() {
    DelayQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(new PDelay(i), q.element());
        q.poll();
    }
    try {
        q.element();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}
 
源代码5 项目: j2objc   文件: DelayQueueTest.java
/**
 * contains(x) reports true when elements added but not yet removed
 */
public void testContains() {
    DelayQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.contains(new PDelay(i)));
        q.poll();
        assertFalse(q.contains(new PDelay(i)));
    }
}