Package java.util.concurrent

Examples of java.util.concurrent.LinkedBlockingQueue$LBQSpliterator


            private AtomicLong queueSizeCounter;

            private MyConsumerQueue(SubscriberConfigProvider.SubscriberConfig subscribe, AtomicLong queueSizeCounter) {
                this.queueSizeCounter = queueSizeCounter;
                q = new LinkedBlockingQueue(EventBusUtils.getQueueSize(subscribe));
            }
View Full Code Here


                                     AtomicLong queueSizeCounter) {
                return testAwareQueue.setQueueSizeCounter(queueSizeCounter);
            }
        });

        LinkedBlockingQueue q = new LinkedBlockingQueue();
    eventBus.enableCatchAllSubscriber(q);
    eventBus.publish(new Event("name", 1));
        assertEquals("No event enqueued to catch all subscriber.", 1, testAwareQueue.offeredCount.get());
        assertNotNull("No event enqueued to catch all subscriber sink under 1 second.", q.poll(1, TimeUnit.SECONDS));
        eventBus.disableCatchAllSubscriber();
        q.clear();
        testAwareQueue.offeredCount.set(0);

        eventBus.publish(new Event("name", 1));
        assertEquals("Event enqueued to catch all subscriber after disable.", 0, testAwareQueue.offeredCount.get());
        assertNull("Event enqueued to catch all subscriber sink under 1 second after disable.", q.poll(1, TimeUnit.SECONDS));
    }
View Full Code Here

            case SizeOrAge:
                return new SizeAndAgeBatchingQueue(subscriber, subscriberConfig, queueSizeCounter);
        }
        return new ConsumerQueue() {

            private LinkedBlockingQueue delegate = new LinkedBlockingQueue(EventBusUtils.getQueueSize(subscriberConfig));

            @Override
            @SuppressWarnings("unchecked")
            public boolean offer(Object event) {
                boolean offered = delegate.offer(event);
                if(offered) {
                    queueSizeCounter.incrementAndGet();
                }
                return offered;
            }

            @Override
            public Object nonBlockingTake() {
                Object retrievedItem = delegate.poll();
                if (null != retrievedItem) {
                    queueSizeCounter.decrementAndGet();
                }
                return retrievedItem;
            }

            @Override
            public Object blockingTake() throws InterruptedException {
                Object retrieved = delegate.take();
                queueSizeCounter.decrementAndGet();
                return retrieved;
            }

            @Override
            public void clear() {
                delegate.clear();
                queueSizeCounter.set(0);
            }
        };
    }
View Full Code Here

        @Override
        public Thread newThread(Runnable ignore) {
            String threadName = node.getThreadPoolNamePrefix("partition-operation") + threadId;
            //each partition operation thread, has its own workqueues because operations are partition specific and can't
            //be executed by other threads.
            LinkedBlockingQueue workQueue = new LinkedBlockingQueue();
            ConcurrentLinkedQueue priorityWorkQueue = new ConcurrentLinkedQueue();
            OperationThread thread = new OperationThread(threadName, true, threadId, workQueue, priorityWorkQueue);
            threadId++;
            return thread;
        }
View Full Code Here

        Processor childProcessor = routeContext.createProcessor(this);
        if (aggregationStrategy == null) {
            aggregationStrategy = new UseLatestAggregationStrategy();
        }
        if (threadPoolExecutor == null) {
            threadPoolExecutor = new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
        }
        return new Splitter(getExpression().createExpression(routeContext), childProcessor, aggregationStrategy,
                isParallelProcessing(), threadPoolExecutor);
    }
View Full Code Here

  public void start() throws AxisFault {
        // create thread pool of workers
       ExecutorService workerPool = new ThreadPoolExecutor(
                1,
                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
                new LinkedBlockingQueue(),
                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
                        new ThreadGroup("XMPP Worker thread group"),
                        "XMPPWorker"));

        Iterator iter = connectionFactories.values().iterator();
View Full Code Here

    // ==================== help method ===========================

    private BlockingQueue<?> getBlockingQueue(int acceptCount, HandleMode mode) {
        if (acceptCount < 0) {
            return new LinkedBlockingQueue();
        } else if (acceptCount == 0) {
            return new ArrayBlockingQueue(1); // 等于0时等价于队列1
        } else {
            return new ArrayBlockingQueue(acceptCount);
        }
View Full Code Here

  /**
   * Construct a new writer
   */
  public XQueueLogWriter()
  {
    msqQ = new LinkedBlockingQueue();
   
    new Thread( this ).start();
  }
View Full Code Here

        // 1. Create a Selector
        selector=Selector.open();

        // Create a thread pool (Executor)
        executor=new ThreadPoolExecutor(MIN_THREAD_POOL_SIZE, MAX_THREAD_POOL_SIZE, 30000, TimeUnit.MILLISECONDS,
                                        new LinkedBlockingQueue(1000));

        for (Iterator it=mappings.keySet().iterator(); it.hasNext();) {
            key=(MyInetSocketAddress) it.next();
            value=(MyInetSocketAddress) mappings.get(key);
View Full Code Here

/*     */   {
/* 100 */     this.eventSourceMapping = new ConcurrentHashMap();
/*     */
/* 102 */     this.subscriptionMapping = new ConcurrentHashMap();
/*     */
/* 104 */     this.eventQueue = new LinkedBlockingQueue();
/*     */
/* 108 */     this.validateNotifications = false;
/*     */
/* 112 */     this.isDispatcherBound = false;
/*     */
View Full Code Here

TOP

Related Classes of java.util.concurrent.LinkedBlockingQueue$LBQSpliterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.