本文整理了Java中java.util.ArrayDeque.add()
方法的一些代码示例,展示了ArrayDeque.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.add()
方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:add
[英]Inserts the specified element at the end of this deque.
This method is equivalent to #addLast.
[中]在此数据块的末尾插入指定的元素。
此方法相当于#addLast。
代码示例来源:origin: apache/flink
@Override
public void add(BufferOrEvent boe) {
bytesBlocked += pageSize;
currentBuffers.add(boe);
}
代码示例来源:origin: netty/netty
/**
* Add a buffer to the end of the queue and associate a listener with it that should be completed when
* all the buffers bytes have been consumed from the queue and written.
* @param buf to add to the tail of the queue
* @param listener to notify when all the bytes have been consumed and written, can be {@code null}.
*/
public final void add(ByteBuf buf, ChannelFutureListener listener) {
// buffers are added before promises so that we naturally 'consume' the entire buffer during removal
// before we complete it's promise.
bufAndListenerPairs.add(buf);
if (listener != null) {
bufAndListenerPairs.add(listener);
}
incrementReadableBytes(buf.readableBytes());
}
代码示例来源:origin: square/okhttp
synchronized boolean pong(ByteString payload) {
// Don't send pongs after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return false;
pongQueue.add(payload);
runWriter();
return true;
}
代码示例来源:origin: square/okhttp
@Override public synchronized void onReadPing(ByteString payload) {
// Don't respond to pings after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return;
pongQueue.add(payload);
runWriter();
receivedPingCount++;
}
代码示例来源:origin: apache/incubator-druid
public DefaultBlockingPool(
Supplier<T> generator,
int limit
)
{
this.objects = new ArrayDeque<>(limit);
this.maxSize = limit;
for (int i = 0; i < limit; i++) {
objects.add(generator.get());
}
this.lock = new ReentrantLock();
this.notEnough = lock.newCondition();
}
代码示例来源:origin: redisson/redisson
/**
* Add a buffer to the end of the queue and associate a listener with it that should be completed when
* all the buffers bytes have been consumed from the queue and written.
* @param buf to add to the tail of the queue
* @param listener to notify when all the bytes have been consumed and written, can be {@code null}.
*/
public final void add(ByteBuf buf, ChannelFutureListener listener) {
// buffers are added before promises so that we naturally 'consume' the entire buffer during removal
// before we complete it's promise.
bufAndListenerPairs.add(buf);
if (listener != null) {
bufAndListenerPairs.add(listener);
}
incrementReadableBytes(buf.readableBytes());
}
代码示例来源:origin: bumptech/glide
@Override
public void put(Bitmap bitmap) {
numPuts++;
bitmaps.add(bitmap);
}
代码示例来源:origin: prestodb/presto
synchronized boolean pong(ByteString payload) {
// Don't send pongs after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return false;
pongQueue.add(payload);
runWriter();
return true;
}
代码示例来源:origin: prestodb/presto
@Override public synchronized void onReadPing(ByteString payload) {
// Don't respond to pings after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return;
pongQueue.add(payload);
runWriter();
pingCount++;
}
代码示例来源:origin: google/ExoPlayer
public CeaDecoder() {
availableInputBuffers = new ArrayDeque<>();
for (int i = 0; i < NUM_INPUT_BUFFERS; i++) {
availableInputBuffers.add(new CeaInputBuffer());
}
availableOutputBuffers = new ArrayDeque<>();
for (int i = 0; i < NUM_OUTPUT_BUFFERS; i++) {
availableOutputBuffers.add(new CeaOutputBuffer());
}
queuedInputBuffers = new PriorityQueue<>();
}
代码示例来源:origin: google/ExoPlayer
private void releaseInputBuffer(CeaInputBuffer inputBuffer) {
inputBuffer.clear();
availableInputBuffers.add(inputBuffer);
}
代码示例来源:origin: google/ExoPlayer
protected void releaseOutputBuffer(SubtitleOutputBuffer outputBuffer) {
outputBuffer.clear();
availableOutputBuffers.add(outputBuffer);
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public synchronized void onReadPing(ByteString payload) {
// Don't respond to pings after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return;
pongQueue.add(payload);
runWriter();
receivedPingCount++;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
synchronized boolean pong(ByteString payload) {
// Don't send pongs after we've failed or sent the close frame.
if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return false;
pongQueue.add(payload);
runWriter();
return true;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
if (data.length() != 8) {
throw new IllegalArgumentException("Ping data must be exactly 8 bytes");
}
handler.writePing(data.getLong(0)).addListener(fut -> {
if (fut.isSuccess()) {
synchronized (Http2ConnectionBase.this) {
pongHandlers.add(pongHandler);
}
} else {
pongHandler.handle(Future.failedFuture(fut.cause()));
}
});
return this;
}
代码示例来源:origin: square/okhttp
synchronized boolean close(int code, String reason, long cancelAfterCloseMillis) {
validateCloseCode(code);
ByteString reasonBytes = null;
if (reason != null) {
reasonBytes = ByteString.encodeUtf8(reason);
if (reasonBytes.size() > CLOSE_MESSAGE_MAX) {
throw new IllegalArgumentException("reason.size() > " + CLOSE_MESSAGE_MAX + ": " + reason);
}
}
if (failed || enqueuedClose) return false;
// Immediately prevent further frames from being enqueued.
enqueuedClose = true;
// Enqueue the close frame.
messageAndCloseQueue.add(new Close(code, reasonBytes, cancelAfterCloseMillis));
runWriter();
return true;
}
代码示例来源:origin: square/okhttp
private synchronized boolean send(ByteString data, int formatOpcode) {
// Don't send new frames after we've failed or enqueued a close frame.
if (failed || enqueuedClose) return false;
// If this frame overflows the buffer, reject it and close the web socket.
if (queueSize + data.size() > MAX_QUEUE_SIZE) {
close(CLOSE_CLIENT_GOING_AWAY, null);
return false;
}
// Enqueue the message frame.
queueSize += data.size();
messageAndCloseQueue.add(new Message(formatOpcode, data));
runWriter();
return true;
}
代码示例来源:origin: prestodb/presto
synchronized boolean close(int code, String reason, long cancelAfterCloseMillis) {
validateCloseCode(code);
ByteString reasonBytes = null;
if (reason != null) {
reasonBytes = ByteString.encodeUtf8(reason);
if (reasonBytes.size() > CLOSE_MESSAGE_MAX) {
throw new IllegalArgumentException("reason.size() > " + CLOSE_MESSAGE_MAX + ": " + reason);
}
}
if (failed || enqueuedClose) return false;
// Immediately prevent further frames from being enqueued.
enqueuedClose = true;
// Enqueue the close frame.
messageAndCloseQueue.add(new Close(code, reasonBytes, cancelAfterCloseMillis));
runWriter();
return true;
}
代码示例来源:origin: wildfly/wildfly
@Override
public void startSequence() throws ASN1Exception {
readTag(SEQUENCE_TYPE);
int length = readLength();
states.add(new DecoderState(SEQUENCE_TYPE, bi.getIndex() + length));
}
代码示例来源:origin: prestodb/presto
private synchronized boolean send(ByteString data, int formatOpcode) {
// Don't send new frames after we've failed or enqueued a close frame.
if (failed || enqueuedClose) return false;
// If this frame overflows the buffer, reject it and close the web socket.
if (queueSize + data.size() > MAX_QUEUE_SIZE) {
close(CLOSE_CLIENT_GOING_AWAY, null);
return false;
}
// Enqueue the message frame.
queueSize += data.size();
messageAndCloseQueue.add(new Message(formatOpcode, data));
runWriter();
return true;
}
内容来源于网络,如有侵权,请联系作者删除!