本文整理了Java中java.util.concurrent.LinkedBlockingDeque.addAll()
方法的一些代码示例,展示了LinkedBlockingDeque.addAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedBlockingDeque.addAll()
方法的具体详情如下:
包路径:java.util.concurrent.LinkedBlockingDeque
类名称:LinkedBlockingDeque
方法名:addAll
暂无
代码示例来源:origin: prestodb/presto
private synchronized boolean addPages(List<SerializedPage> pages)
{
if (isClosed() || isFailed()) {
return false;
}
pageBuffer.addAll(pages);
if (!pages.isEmpty()) {
// notify all blocked callers
notifyBlockedCallers();
}
long pagesRetainedSizeInBytes = pages.stream()
.mapToLong(SerializedPage::getRetainedSizeInBytes)
.sum();
bufferRetainedSizeInBytes += pagesRetainedSizeInBytes;
maxBufferRetainedSizeInBytes = Math.max(maxBufferRetainedSizeInBytes, bufferRetainedSizeInBytes);
systemMemoryContext.setBytes(bufferRetainedSizeInBytes);
successfulRequests++;
long responseSize = pages.stream()
.mapToLong(SerializedPage::getSizeInBytes)
.sum();
// AVG_n = AVG_(n-1) * (n-1)/n + VALUE_n / n
averageBytesPerRequest = (long) (1.0 * averageBytesPerRequest * (successfulRequests - 1) / successfulRequests + responseSize / successfulRequests);
return true;
}
代码示例来源:origin: apache/flume
private void resizeQueue(int capacity) throws InterruptedException {
int oldCapacity;
synchronized (queueLock) {
oldCapacity = queue.size() + queue.remainingCapacity();
}
if (oldCapacity == capacity) {
return;
} else if (oldCapacity > capacity) {
if (!queueRemaining.tryAcquire(oldCapacity - capacity, keepAlive, TimeUnit.SECONDS)) {
LOGGER.warn("Couldn't acquire permits to downsize the queue, resizing has been aborted");
} else {
synchronized (queueLock) {
LinkedBlockingDeque<Event> newQueue = new LinkedBlockingDeque<Event>(capacity);
newQueue.addAll(queue);
queue = newQueue;
}
}
} else {
synchronized (queueLock) {
LinkedBlockingDeque<Event> newQueue = new LinkedBlockingDeque<Event>(capacity);
newQueue.addAll(queue);
queue = newQueue;
}
queueRemaining.release(capacity - oldCapacity);
}
}
代码示例来源:origin: de.vandermeer/skb-interfaces
@Override
default LinkedBlockingDeque<T> get(Collection<T> collection) {
LinkedBlockingDeque<T> ret = new LinkedBlockingDeque<T>();
if(collection!=null){
ret.addAll(collection);
}
return ret;
}
代码示例来源:origin: de.vandermeer/skb-interfaces
@Override
default LinkedBlockingDeque<T> get(Collection<T> collection) {
LinkedBlockingDeque<T> ret = new LinkedBlockingDeque<T>();
if(collection!=null){
ret.addAll(collection);
}
return ret;
}
代码示例来源:origin: org.apache.flume/flume-ng-core
private void resizeQueue(int capacity) throws InterruptedException {
int oldCapacity;
synchronized (queueLock) {
oldCapacity = queue.size() + queue.remainingCapacity();
}
if (oldCapacity == capacity) {
return;
} else if (oldCapacity > capacity) {
if (!queueRemaining.tryAcquire(oldCapacity - capacity, keepAlive, TimeUnit.SECONDS)) {
LOGGER.warn("Couldn't acquire permits to downsize the queue, resizing has been aborted");
} else {
synchronized (queueLock) {
LinkedBlockingDeque<Event> newQueue = new LinkedBlockingDeque<Event>(capacity);
newQueue.addAll(queue);
queue = newQueue;
}
}
} else {
synchronized (queueLock) {
LinkedBlockingDeque<Event> newQueue = new LinkedBlockingDeque<Event>(capacity);
newQueue.addAll(queue);
queue = newQueue;
}
queueRemaining.release(capacity - oldCapacity);
}
}
代码示例来源:origin: NightscoutFoundation/xDrip
@SuppressWarnings("WeakerAccess")
public static void injectQueueJson(String json) {
if (json == null || json.length() == 0) return;
final Type queueType = new TypeToken<ArrayList<Ob1Work>>() {
}.getType();
final List<Ob1Work> queue = JoH.defaultGsonInstance().fromJson(json, queueType);
synchronized (commandQueue) {
commandQueue.clear();
commandQueue.addAll(queue);
}
UserError.Log.d(TAG, "Replaced queue with stream: " + json);
}
代码示例来源:origin: io.prestosql/presto-main
private synchronized boolean addPages(List<SerializedPage> pages)
{
if (isClosed() || isFailed()) {
return false;
}
pageBuffer.addAll(pages);
if (!pages.isEmpty()) {
// notify all blocked callers
notifyBlockedCallers();
}
long pagesRetainedSizeInBytes = pages.stream()
.mapToLong(SerializedPage::getRetainedSizeInBytes)
.sum();
bufferRetainedSizeInBytes += pagesRetainedSizeInBytes;
maxBufferRetainedSizeInBytes = Math.max(maxBufferRetainedSizeInBytes, bufferRetainedSizeInBytes);
systemMemoryContext.setBytes(bufferRetainedSizeInBytes);
successfulRequests++;
long responseSize = pages.stream()
.mapToLong(SerializedPage::getSizeInBytes)
.sum();
// AVG_n = AVG_(n-1) * (n-1)/n + VALUE_n / n
averageBytesPerRequest = (long) (1.0 * averageBytesPerRequest * (successfulRequests - 1) / successfulRequests + responseSize / successfulRequests);
return true;
}
代码示例来源:origin: jamorham/xDrip-plus
@SuppressWarnings("WeakerAccess")
public static void injectQueueJson(String json) {
if (json == null || json.length() == 0) return;
final Type queueType = new TypeToken<ArrayList<Ob1Work>>() {
}.getType();
final List<Ob1Work> queue = JoH.defaultGsonInstance().fromJson(json, queueType);
synchronized (commandQueue) {
commandQueue.clear();
commandQueue.addAll(queue);
}
UserError.Log.d(TAG, "Replaced queue with stream: " + json);
}
代码示例来源:origin: jamorham/xDrip-plus
@SuppressWarnings("WeakerAccess")
public static void injectQueueJson(String json) {
if (json == null || json.length() == 0) return;
final Type queueType = new TypeToken<ArrayList<Ob1Work>>() {
}.getType();
final List<Ob1Work> queue = JoH.defaultGsonInstance().fromJson(json, queueType);
synchronized (commandQueue) {
commandQueue.clear();
commandQueue.addAll(queue);
}
UserError.Log.d(TAG, "Replaced queue with stream: " + json);
}
代码示例来源:origin: prestosql/presto
private synchronized boolean addPages(List<SerializedPage> pages)
{
if (isClosed() || isFailed()) {
return false;
}
pageBuffer.addAll(pages);
if (!pages.isEmpty()) {
// notify all blocked callers
notifyBlockedCallers();
}
long pagesRetainedSizeInBytes = pages.stream()
.mapToLong(SerializedPage::getRetainedSizeInBytes)
.sum();
bufferRetainedSizeInBytes += pagesRetainedSizeInBytes;
maxBufferRetainedSizeInBytes = Math.max(maxBufferRetainedSizeInBytes, bufferRetainedSizeInBytes);
systemMemoryContext.setBytes(bufferRetainedSizeInBytes);
successfulRequests++;
long responseSize = pages.stream()
.mapToLong(SerializedPage::getSizeInBytes)
.sum();
// AVG_n = AVG_(n-1) * (n-1)/n + VALUE_n / n
averageBytesPerRequest = (long) (1.0 * averageBytesPerRequest * (successfulRequests - 1) / successfulRequests + responseSize / successfulRequests);
return true;
}
内容来源于网络,如有侵权,请联系作者删除!