java.util.concurrent.LinkedBlockingDeque.pollLast()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中java.util.concurrent.LinkedBlockingDeque.pollLast()方法的一些代码示例,展示了LinkedBlockingDeque.pollLast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedBlockingDeque.pollLast()方法的具体详情如下:
包路径:java.util.concurrent.LinkedBlockingDeque
类名称:LinkedBlockingDeque
方法名:pollLast

LinkedBlockingDeque.pollLast介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: testcontainers/testcontainers-java

private void waitUntilEnd(Long expiry) throws TimeoutException {
    while (System.currentTimeMillis() < expiry) {
      try {
        OutputFrame frame = frames.pollLast(100, TimeUnit.MILLISECONDS);

        if (frame == OutputFrame.END) {
          return;
        }

        if (frames.isEmpty()) {
          // sleep for a moment to avoid excessive CPU spinning
          Thread.sleep(10L);
        }
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    throw new TimeoutException("Expiry time reached before end of output");
  }
}

代码示例来源:origin: apache/usergrid

@Override
  public void run() {
    synchronized ( isOpen ) {
      // Keep writing after closed until buffer is flushed (empty)
      while ( isOpen.get() || !buffer.isEmpty() ) {
        try {
          Result result = buffer.pollLast( waitTime.get(), TimeUnit.MILLISECONDS );

          if ( result != null ) {
            resultCount.incrementAndGet();
            jgen.writeObject( result );
          }
        }
        catch ( InterruptedException e ) {
          LOG.error( "ResultLog thread interrupted.", e );
        }
        catch ( JsonProcessingException e ) {
          LOG.error( "Failed to generate the JSON for a result.", e );
        }
        catch ( IOException e ) {
          LOG.error( "Failed to write JSON to output stream for a result", e );
        }
      }

      isOpen.notifyAll();
    }
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

private void waitUntil(Predicate<OutputFrame> predicate, long expiry, int times) throws TimeoutException {
  int numberOfMatches = 0;
  while (System.currentTimeMillis() < expiry) {
    try {
      OutputFrame frame = frames.pollLast(100, TimeUnit.MILLISECONDS);
      if (frame != null) {
        final String trimmedFrameText = frame.getUtf8String().replaceFirst("\n$", "");
        LOGGER.debug("{}: {}", frame.getType(), trimmedFrameText);
        if (predicate.test(frame)) {
          numberOfMatches++;
          if (numberOfMatches == times) {
            return;
          }
        }
      }
      if (frames.isEmpty()) {
        // sleep for a moment to avoid excessive CPU spinning
        Thread.sleep(10L);
      }
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
  // did not return before expiry was reached
  throw new TimeoutException();
}

代码示例来源:origin: apache/hbase

@Override
public CallRunner poll() {
 CallRunner cr;
 boolean switched = false;
 while(true) {
  if (((double) queue.size() / this.maxCapacity) > lifoThreshold) {
   // Only count once per switch.
   if (!switched) {
    switched = true;
    numLifoModeSwitches.increment();
   }
   cr = queue.pollLast();
  } else {
   switched = false;
   cr = queue.pollFirst();
  }
  if (cr == null) {
   return cr;
  }
  if (needToDrop(cr)) {
   numGeneralCallsDropped.increment();
   cr.drop();
  } else {
   return cr;
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

case OVERFLOW_DROP_LAST: {
  queue.pollLast(); 
  break;

代码示例来源:origin: MobiVM/robovm

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: ibinti/bugvm

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E removeLast() {
  E x = pollLast();
  if (x == null) throw new NoSuchElementException();
  return x;
}

代码示例来源:origin: andforce/iBeebo

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  if (!e.isShutdown()) {
    LinkedBlockingDeque<Runnable> deque = (LinkedBlockingDeque) e.getQueue();
    Runnable runnable = deque.pollLast();
    if (runnable instanceof FutureTask) {
      FutureTask futureTask = (FutureTask) runnable;
      futureTask.cancel(true);
      CANCEL_OPERATION__THREAD_POOL_EXECUTOR.execute(futureTask);
    }
    e.execute(r);
  }
}

代码示例来源:origin: andforce/iBeebo

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
    if (!e.isShutdown()) {
      LinkedBlockingDeque<Runnable> deque = (LinkedBlockingDeque<Runnable>) e.getQueue();
      Runnable runnable = deque.pollLast();
      if (runnable instanceof FutureTask) {
        FutureTask<?> futureTask = (FutureTask<?>) runnable;
        futureTask.cancel(true);
        CANCEL_OPERATION__THREAD_POOL_EXECUTOR.execute(futureTask);
      }
      e.execute(r);
    }
  }
});

代码示例来源:origin: com.crawljax/crawljax

/**
 * Register an assignment to the crawler.
 * 
 * @param newCrawler
 *            the crawler that wants an assignment
 * @return true if the crawler has an assignment false otherwise.
 */
public boolean registerCrawler(Crawler newCrawler) {
  CandidateCrawlAction action = candidateActions.pollLast();
  if (action == null) {
    return false;
  }
  registeredCrawlers.offerFirst(newCrawler);
  registerdCandidateActions.put(newCrawler, action);
  return true;
}

代码示例来源:origin: org.testcontainers/testcontainers

private void waitUntilEnd(Long expiry) throws TimeoutException {
    while (System.currentTimeMillis() < expiry) {
      try {
        OutputFrame frame = frames.pollLast(100, TimeUnit.MILLISECONDS);

        if (frame == OutputFrame.END) {
          return;
        }

        if (frames.isEmpty()) {
          // sleep for a moment to avoid excessive CPU spinning
          Thread.sleep(10L);
        }
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    throw new TimeoutException("Expiry time reached before end of output");
  }
}

代码示例来源:origin: andforce/iBeebo

@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);
    }
  }
});

相关文章

微信公众号

最新文章

更多