BlockingQueue add - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for BlockingQueue add method.

This code example shows how to use the following methods:add
	 * able to create new connections.  
	 * @throws SQLException  
	 * @throws CloneNotSupportedException */ 
	@Test 
	public void testConnectionMarkedBroken() throws SQLException, CloneNotSupportedException { 
		BlockingQueue<ConnectionHandle> fakeFreeConnections = new LinkedBlockingQueue<ConnectionHandle>(100);
		fakeFreeConnections.add(mockConnection);
		 
		BoneCPConfig localconfig = config.clone();
		expect(mockPool.getConfig()).andReturn(localconfig).anyTimes();
		expect(mockConnectionPartition.getAvailableConnections()).andReturn(1).anyTimes();
 
		expect(mockConnectionPartition.getFreeConnections()).andReturn(fakeFreeConnections).anyTimes();
 		expect(mockConnection.isPossiblyBroken()).andReturn(true);
		 
		// connection should be closed 
		mockConnection.internalClose();
		mockPool.postDestroyConnection(mockConnection);
		expectLastCall().once(); 
		replay(mockPool, mockConnection, mockConnectionPartition, mockExecutor);
7
CodeRank
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
This code example shows how to use the following methods:add
	 * able to create new connections.  
	 * @throws SQLException  
	 * @throws CloneNotSupportedException */ 
	@Test
	public void testConnectionMarkedBroken() throws SQLException, CloneNotSupportedException {
		BlockingQueue<ConnectionHandle> fakeFreeConnections = new LinkedBlockingQueue<ConnectionHandle>(100);
		fakeFreeConnections.add(mockConnection);
		 
		BoneCPConfig localconfig = config.clone();
		expect(mockPool.getConfig()).andReturn(localconfig).anyTimes();
		expect(mockConnectionPartition.getAvailableConnections()).andReturn(1).anyTimes();
 
		expect(mockConnectionPartition.getFreeConnections()).andReturn(fakeFreeConnections).anyTimes();
 		expect(mockConnection.isPossiblyBroken()).andReturn(true);
		 
		// connection should be closed 
		mockConnection.internalClose();
		mockPool.postDestroyConnection(mockConnection);
		expectLastCall().once(); 
		replay(mockPool, mockConnection, mockConnectionPartition, mockExecutor);
6
CodeRank
This code example shows how to use the following methods:add
        failure.setStackTrace(adjusted.toArray(new StackTraceElement[adjusted.size()]));
        return failure;
    } 
 
    public void onComplete(T result) {
        queue.add(result == null ? NULL : result);
    } 
 
    public void onFailure(GradleConnectionException failure) {
        queue.add(failure);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:size, peek, add
     * 通知下一个minTimestamp数据出队列 
     *  
     * @throws InterruptedException 
     */ 
    private void single(long timestamp) throws InterruptedException {
        lastTimestamps.add(timestamp);
 
        if (timestamp < state()) {
            // 针对mysql事务中会出现时间跳跃 
            // 例子: 
            // 2012-08-08 16:24:26 事务头 
            // 2012-08-08 16:24:24 变更记录 
            // 2012-08-08 16:24:25 变更记录 
            // 2012-08-08 16:24:26 事务尾 
 
            // 针对这种case,一旦发现timestamp有回退的情况,直接更新threshold,强制阻塞其他的操作,等待最小数据优先处理完成 
            threshold = timestamp; // 更新为最小值
        } 
 
        if (lastTimestamps.size() >= groupSize) {// 判断队列是否需要触发

7
CodeRank
This code example shows how to use the following methods:add
    if (failFastResponse != null) return failFastResponse;
    return super.peek(); 
  } 
 
  public void enqueueResponse(MockResponse response) {
    responseQueue.add(response);
  } 
 
  public void setFailFast(boolean failFast) {
    MockResponse failFastResponse = failFast
        ? new MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)
        : null; 
    setFailFast(failFastResponse);
  } 
 
  public void setFailFast(MockResponse failFastResponse) {
    this.failFastResponse = failFastResponse;
  } 
} 
6
CodeRank
This code example shows how to use the following methods:add
 
    public void taskCompleted(ForkJoinTask<PT> task)
    { 
        if (this.combiner.useCombineOne())
        { 
            this.outputQueue.add(task.getRawResult());
        } 
    } 
 
    public void executeAndCombine(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, BatchIterable<T> list)
    { 
        FastList<ForkJoinTask<PT>> tasks = this.createAndExecuteTasks(executor, procedureFactory, list);
        if (this.combiner.useCombineOne())
        { 
            this.join();
        } 
        if (this.error != null)
        { 
            throw new RuntimeException("One or more parallel tasks failed", this.error);
        } 
6
CodeRank
This code example shows how to use the following methods:add
 
    public void taskCompleted(ForkJoinTask<PT> task)
    { 
        if (this.combiner.useCombineOne())
        { 
            this.outputQueue.add(task.getRawResult());
        } 
    } 
 
    public void executeAndCombine(ForkJoinPool executor, ObjectIntProcedureFactory<PT> procedureFactory, List<T> list)
    { 
        FastList<ForkJoinTask<PT>> tasks = this.createAndExecuteTasks(executor, procedureFactory, list);
        if (this.combiner.useCombineOne())
        { 
            this.join();
        } 
        if (this.error != null)
        { 
            throw new RuntimeException("One or more parallel tasks failed", this.error);
        } 
6
CodeRank
This code example shows how to use the following methods:add
    return encoder; 
  } 
 
  @Override 
  public void checkIn(PrefixTreeEncoder encoder) { 
    this.unusedEncoders.add(encoder); 
  } 
} 
5
CodeRank
This code example shows how to use the following methods:add
 
    public void taskCompleted(ForkJoinTask<PT> task)
    { 
        if (this.combiner.useCombineOne())
        { 
            this.outputQueue.add(task.getRawResult());
        } 
    } 
 
    public void executeAndCombine(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, List<T> list)
    { 
        FastList<ForkJoinTask<PT>> tasks = this.createAndExecuteTasks(executor, procedureFactory, list);
        if (this.combiner.useCombineOne())
        { 
            this.join();
        } 
        if (this.error != null)
        { 
            throw new RuntimeException("One or more parallel tasks failed", this.error);
        } 
6
CodeRank
add Method Overview
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
See Code Examples for other Java 8 BlockingQueue Methods: