当前位置: 首页>>代码示例>>Java>>正文


Java BlockingQueue.remainingCapacity方法代码示例

本文整理汇总了Java中java.util.concurrent.BlockingQueue.remainingCapacity方法的典型用法代码示例。如果您正苦于以下问题:Java BlockingQueue.remainingCapacity方法的具体用法?Java BlockingQueue.remainingCapacity怎么用?Java BlockingQueue.remainingCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.BlockingQueue的用法示例。


在下文中一共展示了BlockingQueue.remainingCapacity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRemainingCapacity

import java.util.concurrent.BlockingQueue; //导入方法依赖的package包/类
/**
 * remainingCapacity decreases on add, increases on remove
 */
public void testRemainingCapacity() {
    int size = ThreadLocalRandom.current().nextInt(1, SIZE);
    BlockingQueue q = populatedQueue(size, size, 2 * size, false);
    int spare = q.remainingCapacity();
    int capacity = spare + size;
    for (int i = 0; i < size; i++) {
        assertEquals(spare + i, q.remainingCapacity());
        assertEquals(capacity, q.size() + q.remainingCapacity());
        assertEquals(i, q.remove());
    }
    for (int i = 0; i < size; i++) {
        assertEquals(capacity - i, q.remainingCapacity());
        assertEquals(capacity, q.size() + q.remainingCapacity());
        assertTrue(q.add(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ArrayBlockingQueueTest.java

示例2: remainingCapacity

import java.util.concurrent.BlockingQueue; //导入方法依赖的package包/类
/**
 * Returns maximum remaining capacity. This does not reflect how much you can
 * ideally fit in this FairCallQueue, as that would depend on the scheduler's
 * decisions.
 */
@Override
public int remainingCapacity() {
  int sum = 0;
  for (BlockingQueue q : this.queues) {
    sum += q.remainingCapacity();
  }
  return sum;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:FairCallQueue.java

示例3: getThrottledVirtualSpoutIdentifiers

import java.util.concurrent.BlockingQueue; //导入方法依赖的package包/类
/**
 * Internal method used *ONLY* within tests.  Hacky implementation -- could have race-conditions in other use-cases.
 * @return Set of all VirtualSpoutIds that ARE throttled.
 */
Set<VirtualSpoutIdentifier> getThrottledVirtualSpoutIdentifiers() {
    Set<VirtualSpoutIdentifier> throttledVirtualSpoutIds = new HashSet<>();

    for (Map.Entry<VirtualSpoutIdentifier, BlockingQueue<Message>> entry: messageBuffer.entrySet()) {
        BlockingQueue<Message> queue = entry.getValue();
        if (queue.remainingCapacity() + queue.size() == getThrottledBufferSize()) {
            throttledVirtualSpoutIds.add(entry.getKey());
        }
    }
    return throttledVirtualSpoutIds;
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:16,代码来源:ThrottledMessageBuffer.java

示例4: getNonThrottledVirtualSpoutIdentifiers

import java.util.concurrent.BlockingQueue; //导入方法依赖的package包/类
/**
 * Internal method used *ONLY* within tests.  Hacky implementation -- could have race-conditions in other use-cases.
 * @return Set of all VirtualSpoutIds that are NOT throttled.
 */
Set<VirtualSpoutIdentifier> getNonThrottledVirtualSpoutIdentifiers() {
    Set<VirtualSpoutIdentifier> nonThrottledVirtualSpoutIds = new HashSet<>();

    for (Map.Entry<VirtualSpoutIdentifier, BlockingQueue<Message>> entry: messageBuffer.entrySet()) {
        BlockingQueue<Message> queue = entry.getValue();
        if (queue.remainingCapacity() + queue.size() > getThrottledBufferSize()) {
            nonThrottledVirtualSpoutIds.add(entry.getKey());
        }
    }
    return nonThrottledVirtualSpoutIds;
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:16,代码来源:ThrottledMessageBuffer.java

示例5: saturatedSize

import java.util.concurrent.BlockingQueue; //导入方法依赖的package包/类
/**
 * Returns maximum number of tasks that can be submitted to given
 * pool (with bounded queue) before saturation (when submission
 * throws RejectedExecutionException).
 */
static final int saturatedSize(ThreadPoolExecutor pool) {
    BlockingQueue<Runnable> q = pool.getQueue();
    return pool.getMaximumPoolSize() + q.size() + q.remainingCapacity();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:JSR166TestCase.java


注:本文中的java.util.concurrent.BlockingQueue.remainingCapacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。