| Modifier and Type | Field and Description |
|---|---|
| private final AllocationType | |
| private volatile boolean | |
| private final MemoryManager |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Buffer | allocate(int
The size of size)Buffer to allocate.Implements io. Buffer of the given size in bytes.
|
| public void | close()
Implements io. |
| public Supplier | constBufferSupplier(byte[]
The byte contents of the buffers produced by the returned supplier. bytes)Implements io. |
| public Buffer | copyOf(String
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.Overrides default io. Buffer with the same size and contents of the given String,
when interpreted as a sequence of bytes with the given Charset.
|
| public AllocationType | getAllocationType()
Implements io. AllocationType from this allocator.
|
| public BufferAllocator | getAllocator()
Implements io. BufferAllocator instance that is the source of this allocator control.
|
| public boolean | isPooling()
Implements io. |
| allocationType | back to summary |
|---|---|
| private final AllocationType allocationType | |
| closed | back to summary |
|---|---|
| private volatile boolean closed | |
| manager | back to summary |
|---|---|
| private final MemoryManager manager | |
| ManagedBufferAllocator | back to summary |
|---|---|
| pack-priv ManagedBufferAllocator(MemoryManager manager, boolean direct) | |
| allocate | back to summary |
|---|---|
| public Buffer allocate(int size) Implements io. Doc from io. Allocate a The buffer will use big endian byte order. Note unlike the JDK | |
| close | back to summary |
|---|---|
| public void close() Implements io. Doc from 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
| |
| constBufferSupplier | back to summary |
|---|---|
| public Supplier Implements io. Doc from io. 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 Buffer copyOf(String str, Charset charset) Overrides default io. Doc from io. Allocate a The allocated buffer will use big endian byte order. | |
| getAllocationType | back to summary |
|---|---|
| public AllocationType getAllocationType() Implements io. Doc from io. Get the
| |
| getAllocator | back to summary |
|---|---|
| public BufferAllocator getAllocator() Implements io. Doc from io. Get the
| |
| isPooling | back to summary |
|---|---|
| public boolean isPooling() Implements io. Doc from io. Determine if this allocator is pooling and reusing its allocated memory.
| |