Java Code Examples for java.util.concurrent.LinkedBlockingDeque#pollLast()

The following examples show how to use java.util.concurrent.LinkedBlockingDeque#pollLast() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * peekFirst returns element inserted with addFirst
 */
public void testAddFirst() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.addFirst(four);
    assertSame(four, q.peekFirst());
}
 
Example 2
/**
 * peekLast returns element inserted with addLast
 */
public void testAddLast() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.addLast(four);
    assertSame(four, q.peekLast());
}
 
Example 3
/**
 * peekFirst returns element inserted with push
 */
public void testPushWithPeek() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.push(four);
    assertSame(four, q.peekFirst());
}
 
Example 4
Source Project: iBeebo   File: TaskCache.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    if (!e.isShutdown()) {
        LinkedBlockingDeque<Runnable> deque = (LinkedBlockingDeque) e.getQueue();
        Runnable runnable = deque.pollLast();
        if (runnable instanceof DownloadFutureTask) {
            DownloadFutureTask futureTask = (DownloadFutureTask) runnable;
            futureTask.cancel(true);
            String url = futureTask.getUrl();
            removeDownloadTask(url, futureTask);
        }
        e.execute(r);
    }
}
 
Example 5
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * peekFirst returns element inserted with addFirst
 */
public void testAddFirst() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.addFirst(four);
    assertSame(four, q.peekFirst());
}
 
Example 6
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * peekLast returns element inserted with addLast
 */
public void testAddLast() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.addLast(four);
    assertSame(four, q.peekLast());
}
 
Example 7
Source Project: j2objc   File: LinkedBlockingDequeTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * peekFirst returns element inserted with push
 */
public void testPushWithPeek() {
    LinkedBlockingDeque q = populatedDeque(3);
    q.pollLast();
    q.push(four);
    assertSame(four, q.peekFirst());
}
 
Example 8
Source Project: iBeebo   File: TaskCache.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    if (!e.isShutdown()) {
        LinkedBlockingDeque<Runnable> deque = (LinkedBlockingDeque) e.getQueue();
        Runnable runnable = deque.pollLast();
        if (runnable instanceof DownloadFutureTask) {
            DownloadFutureTask futureTask = (DownloadFutureTask) runnable;
            futureTask.cancel(true);
            String url = futureTask.getUrl();
            removeDownloadTask(url, futureTask);
        }
        e.execute(r);
    }
}