Top Description Inners Fields Constructors Methods
org.apache.tomcat.util.net

public Class WriteBuffer

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.ArrayList, .Iterator, .List, java.util.concurrent.LinkedBlockingDeque, org.apache.tomcat.util.buf.ByteBufferHolder

Provides an expandable set of buffers for writes. Non-blocking writes can be of any size and may not be able to be written immediately or wholly contained in the buffer used to perform the writes to the next layer. This class provides a buffering capability to allow such writes to return immediately and also allows for the user provided buffers to be re-used / recycled as required.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
WriteBuffer.Sink

Interface implemented by clients of the WriteBuffer to enable data to be written back out from the buffer.

Field Summary

Modifier and TypeField and Description
private final LinkedBlockingDeque<ByteBufferHolder>
private final int

Constructor Summary

AccessConstructor and Description
public
WriteBuffer(int bufferSize)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(byte[] buf, int offset, int length)

public void
pack-priv void
private ByteBufferHolder
getByteBufferHolder(int capacity)

public boolean
pack-priv ByteBuffer[]

Returns:

an array of ByteBuffers from the current WriteBuffer prefixed by the provided ByteBuffers
toArray
(ByteBuffer...
The additional ByteBuffers to add to the start of the array
prefixes
)

Create an array of ByteBuffers from the current WriteBuffer, prefixing that array with the provided ByteBuffers.

pack-priv boolean
write(SocketWrapperBase<?> socketWrapper, boolean blocking)

public boolean
write(WriteBuffer.Sink sink, boolean blocking)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

buffersback to summary
private final LinkedBlockingDeque<ByteBufferHolder> buffers
bufferSizeback to summary
private final int bufferSize

Constructor Detail

WriteBufferback to summary
public WriteBuffer(int bufferSize)

Method Detail

addback to summary
pack-priv void add(byte[] buf, int offset, int length)
addback to summary
public void add(ByteBuffer from)
clearback to summary
pack-priv void clear()
getByteBufferHolderback to summary
private ByteBufferHolder getByteBufferHolder(int capacity)
isEmptyback to summary
public boolean isEmpty()
toArrayback to summary
pack-priv ByteBuffer[] toArray(ByteBuffer... prefixes)

Create an array of ByteBuffers from the current WriteBuffer, prefixing that array with the provided ByteBuffers.

Parameters
prefixes:ByteBuffer[]

The additional ByteBuffers to add to the start of the array

Returns:ByteBuffer[]

an array of ByteBuffers from the current WriteBuffer prefixed by the provided ByteBuffers

writeback to summary
pack-priv boolean write(SocketWrapperBase<?> socketWrapper, boolean blocking) throws IOException
writeback to summary
public boolean write(WriteBuffer.Sink sink, boolean blocking) throws IOException
org.apache.tomcat.util.net back to summary

public Interface WriteBuffer.Sink

Known Direct Implementers
org.apache.coyote.http2.Stream.StreamOutputBuffer

Interface implemented by clients of the WriteBuffer to enable data to be written back out from the buffer.

Method Summary

Modifier and TypeMethod and Description
public boolean
writeFromBuffer(ByteBuffer buffer, boolean block)

Method Detail

writeFromBufferback to summary
public boolean writeFromBuffer(ByteBuffer buffer, boolean block) throws IOException