T - Source type.TT - Target type.@Beta
public abstract class AllocatingTransformer<T,TT>
extends java.lang.Object
Connection.
Observable.map(), however, while writing on a
Connection, typically one requires to allocate buffers. Although a Connection provides a way to
retrieve the ByteBufAllocator via the Channel, allocating buffers from outside the eventloop will
lead to buffer bloats as the allocators will typically use thread-local buffer pools. This transformer is always invoked from within the eventloop and hence does not have buffer bloating issues, even when transformations happen outside the eventloop.
| Modifier | Constructor and Description |
|---|---|
protected |
AllocatingTransformer() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
acceptMessage(java.lang.Object msg)
Asserts whether the passed message can be transformed using this transformer.
|
abstract java.util.List<TT> |
transform(T toTransform,
io.netty.buffer.ByteBufAllocator allocator)
Transforms the passed message and adds the output to the returned list.
|
protected boolean acceptMessage(java.lang.Object msg)
msg - Message to transform.true if the message can be transformed.public abstract java.util.List<TT> transform(T toTransform, io.netty.buffer.ByteBufAllocator allocator)
toTransform - Message to transform.allocator - Allocating for allocating buffers, if required.