Java 8 LinkedBlockingDeque - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 LinkedBlockingDeque class.

This code example shows how to use the following methods:offer, remove
        return deque.size();
    } 
 
    public void add(long i)
    { 
        if (!deque.offer(i))
        { 
            Long removed = deque.remove();
            sum.addAndGet(-removed);
            deque.offer(i);
        } 
        sum.addAndGet(i);
    } 
 
    public long sum() 
    { 
        return sum.get();
    } 
 
    public double mean() 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 * @author Stuart Douglas 
 */ 
@ClientEndpoint 
public class AnnotatedClient { 
 
    private final BlockingDeque<String> queue = new LinkedBlockingDeque<>();
 
    @OnOpen 
    public void open(final Session session) throws IOException {
        session.getBasicRemote().sendText("Hello");
    } 
 
    @OnMessage 
    public void message(final String message) {
        queue.add(message);
    } 
 
    public String getMessage() throws InterruptedException {
        return queue.poll(5, TimeUnit.SECONDS);
    } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    public static boolean injectionOK = false;
 
    private static String name;
 
    private static final BlockingDeque<String> queue = new LinkedBlockingDeque<>();
 
    @Inject 
    private Alpha alpha;
 
    @Inject 
    public AnnotatedClient(@ProducedString String name) {
        AnnotatedClient.name = name + "#AnnotatedClient";
    } 
 
    @Inject 
    public void setBravo(Bravo bravo) {
        injectionOK = (alpha != null) && (bravo != null) && (name != null);
    } 
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:size, add
        Message msg = new Message();
        Message msg1 = new Message();
        Message msg2 = new Message();
        Message msg3 = new Message();
 
        BlockingQueue<Message> buffer = new LinkedBlockingDeque<Message>();
 
        buffer.add(msg);
        buffer.add(msg1);
        buffer.add(msg2);
        buffer.add(msg3);
 
        List<Message> list = new ArrayList<Message>();
        CGUtils.moveElements(buffer, list, blockSize);
 
        assertEquals("Some elements are missing", 4, list.size());
        assertEquals("Some elements are still there to drain", 0, buffer.size());
    } 
 
    public void testGetStringProperty() throws Exception { 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add, poll
		private boolean isclick_2 = false;
		private String pid = null;
 
		private String prepid = null;
 
		java.util.concurrent.LinkedBlockingDeque<pid_type> querylist = new LinkedBlockingDeque<aplus_text.DataIterParse.pid_type>();
 
		public static class pid_type { 
			public String pid = "";
			public String tid = "";
			public String matchUrl="";
			public boolean isshaoma;
		} 
 
		pid_type curr = null;
 
 
		private String fetch(boolean isshaoma,String type,String lwfrom, String strday) {
			if (lwfrom == null || lwfrom.isEmpty()) {
				return null; 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:offer, poll
  } 
 
  void add(double i) {
    if (intervalupdates.intValue() >= UPDATES_PER_INTERVAL)
      return; 
    if (!latencies.offer(i)) {
      latencies.poll();
      latencies.offer(i);
    } 
    intervalupdates.getAndIncrement();
  } 
 
  double score() { 
    double log = 0d;
    if (latencies.size() > 0) {
      double probability = p(SENTINEL_COMPARE);
      log = (-1) * Math.log10(probability);
    } 
    return log;
  } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFirst, size
        int maxCount = config.getConnectionLimiterMaxPendingCount();
        if (maxCount == 0)
            return true; 
 
        // Haven't reached the count limit yet 
        if (queue.size() < maxCount) {
            queue.addFirst(currentTimeMillis);
            return true; 
        } 
        else { 
            long last = queue.getLast();
            if (currentTimeMillis - last < config.getConnectionLimiterWindowSize()) {
                return false; 
            } 
            queue.addFirst(currentTimeMillis);
            queue.removeLast();
            return true; 
        } 
    } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
	private WebSocketSession webSocketSession;
 
	private volatile boolean openFrameSent;
 
	private final Queue<String> initSessionCache = new LinkedBlockingDeque<String>();
 
	private final Object initSessionLock = new Object(); 
 
	private volatile boolean disconnected;
 
 
	public WebSocketServerSockJsSession(String id, SockJsServiceConfig config,
			WebSocketHandler handler, Map<String, Object> attributes) {
 
		super(id, config, handler, attributes);
	} 
 
 
	@Override 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        queues.add(new ConcurrentLinkedDeque<Boolean>());
        queues.add(new ConcurrentLinkedQueue<Boolean>());
        queues.add(new ArrayBlockingQueue<Boolean>(count, false));
        queues.add(new ArrayBlockingQueue<Boolean>(count, true));
        queues.add(new LinkedBlockingQueue<Boolean>());
        queues.add(new LinkedBlockingDeque<Boolean>());
        queues.add(new PriorityBlockingQueue<Boolean>());
        queues.add(new PriorityQueue<Boolean>());
        queues.add(new LinkedList<Boolean>());
        queues.add(new LinkedTransferQueue<Boolean>());
 
        // Following additional implementations are available from: 
        // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html 
        // queues.add(new SynchronizedLinkedListQueue<Boolean>()); 
 
        // Avoid "first fast, second slow" benchmark effect. 
        Collections.shuffle(queues);
        return queues;
    } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
class UnknownCommandProcessor implements RequestProcessor 
{ 
	 
	private static final ExecutorService UNKNOWN_COMMAND_PROCESSOR_EXECUTOR = 
			new ThreadPoolExecutor(1, 1, Integer.MAX_VALUE, TimeUnit.DAYS, 
			                       new LinkedBlockingDeque<Runnable>());
 
	@Override 
	public ExecutorService getExecutorService() {
		return UNKNOWN_COMMAND_PROCESSOR_EXECUTOR;
	} 
 
	@Override 
	public DatabusRequest process(DatabusRequest request) throws IOException {
		request.setError(new UnknownCommandException(request.getName()));
		return request;
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 LinkedBlockingDeque Methods: