Buffers.
| Modifier and Type | Method and Description |
|---|---|
| public Buffer | |
| public void | close()
Redeclares io. |
| public default CompositeBuffer | |
| public default CompositeBuffer | |
| public default CompositeBuffer | Returns: A composite buffer that has no components, and has a capacity of zero.Create an empty composite buffer, that has no components. |
| public Supplier | Returns: A supplier of read-only buffers with the given contents.The byte contents of the buffers produced by the returned supplier. bytes)Create a supplier of "constant" Buffers from this allocator, that all have the given byte contents. |
| public default Buffer | |
| public default Buffer | Returns: The newly allocatedBuffer.The str, Charset String that determines the size and contents of the new buffer.The charset)Charset that determines how to turn the string into a sequence of bytes.Allocate a |
| public default Buffer | Returns: The newly allocatedBuffer.The byte buffer, whose contents determine the capacity and contents of the allocated buffer. buffer)Allocate a |
| public AllocationType | Returns: The type of allocations performed by this allocator.Get the |
| public boolean | Returns: true if this allocator is pooling and reusing its memory, false otherwise.Determine if this allocator is pooling and reusing its allocated memory. |
| public static BufferAllocator | Returns: A pooling allocator of on-heap buffersProduces a pooling |
| public static BufferAllocator | Returns: A non-pooling allocator of on-heap buffersProduces a |
| public static BufferAllocator | Returns: A pooling allocator of on-heap buffersProduces a pooling |
| public static BufferAllocator | Returns: A non-pooling allocator of on-heap buffersProduces a |
| allocate | back to summary |
|---|---|
| public Buffer allocate(int size) Allocate a The buffer will use big endian byte order. Note unlike the JDK
| |
| close | back to summary |
|---|---|
| public void close() Redeclares io. Close this allocator, freeing all of its internal resources. Existing (currently in-use) allocated buffers will not be impacted by calling this method. If this is a pooling or caching allocator, then existing buffers will be immediately freed when they are closed, instead of being pooled or cached.
The allocator can no longer be used to allocate more buffers after calling this method.
Attempting to allocate from a closed allocator will cause
| |
| compose | back to summary |
|---|---|
| public default CompositeBuffer compose(Send<Buffer> send) Compose the send of a buffer and present them as a single buffer. When a composite buffer is closed, all of its constituent component buffers are closed as well. See the class documentation for more information on how buffers compose, and what is required of the given buffers for composition to be allowed.
| |
| compose | back to summary |
|---|---|
| public default CompositeBuffer compose(Iterable<Send<Buffer>> sends) Compose the given sequence of sends of buffers and present them as a single buffer. When a composite buffer is closed, all of its constituent component buffers are closed as well. See the class documentation for more information on how buffers compose, and what is required of the given buffers for composition to be allowed.
| |
| compose | back to summary |
|---|---|
| public default CompositeBuffer compose() Create an empty composite buffer, that has no components. The buffer can be extended with components using either
| |
| constBufferSupplier | back to summary |
|---|---|
| public Supplier Create a supplier of "constant" Buffers from this allocator, that all have the given byte contents. The buffer has the same capacity as the byte array length, and its write offset is placed at the end, and its read offset is at the beginning, such that the entire buffer contents are readable. The buffers produced by the supplier will each have their own independent life-cycle, and closing them will make them inaccessible, just like normally allocated buffers. The buffers produced are "constants", in the sense that they are read-only. It can generally be expected, but is not guaranteed, that the returned supplier is more resource efficient than allocating and copying memory with other available APIs. In such optimised implementations, the underlying memory baking the buffers will be shared among all the buffers produced by the supplier.
The primary use case for this API, is when you need to repeatedly produce buffers with the same contents, and
you perhaps wish to keep a
| |
| copyOf | back to summary |
|---|---|
| public default Buffer copyOf(byte[] bytes) Allocate a The allocated buffer will use big endian byte order.
| |
| copyOf | back to summary |
|---|---|
| public default Buffer copyOf(String str, Charset charset) Allocate a The allocated buffer will use big endian byte order. | |
| copyOf | back to summary |
|---|---|
| public default Buffer copyOf(ByteBuffer buffer) Allocate a The allocated buffer will use big endian byte order, regardless of the byte order of the given buffer. The contents of the byte buffer will be copied without regard to the byte order, as if the bytes are copied one at a time.
| |
| getAllocationType | back to summary |
|---|---|
| public AllocationType getAllocationType() Get the
| |
| isPooling | back to summary |
|---|---|
| public boolean isPooling() Determine if this allocator is pooling and reusing its allocated memory.
| |
| offHeapPooled | back to summary |
|---|---|
| public static BufferAllocator offHeapPooled() Produces a pooling
The concrete Note This method always creates a new allocator instance.
To get a shared and cached allocator instance, use the
| |
| offHeapUnpooled | back to summary |
|---|---|
| public static BufferAllocator offHeapUnpooled() Produces a
The concrete Note This method always creates a new allocator instance.
To get a shared and cached allocator instance, use the
| |
| onHeapPooled | back to summary |
|---|---|
| public static BufferAllocator onHeapPooled() Produces a pooling
The concrete Note This method always creates a new allocator instance.
To get a shared and cached allocator instance, use the
| |
| onHeapUnpooled | back to summary |
|---|---|
| public static BufferAllocator onHeapUnpooled() Produces a
The concrete Note This method always creates a new allocator instance.
To get a shared and cached allocator instance, use the
| |