public static interface NettyConnection.RequestNSupplier
n
for calls to PublisherSource.Subscription.request(long)
per
PublisherSource.Subscription
.
A new NettyConnection.RequestNSupplier
is created for each Publisher
that is written.
Any method of an instance of NettyConnection.RequestNSupplier
will never be called concurrently with the same or
other methods of the same instance.
This means that implementations do not have to worry about thread-safety.Modifier and Type | Method and Description |
---|---|
static NettyConnection.RequestNSupplier |
newDefaultSupplier()
Returns a new instance of a default implementation of
NettyConnection.RequestNSupplier . |
void |
onItemWrite(java.lang.Object written,
long writeBufferCapacityBeforeWrite,
long writeBufferCapacityAfterWrite)
Callback whenever an item is written on the connection.
|
long |
requestNFor(long writeBufferCapacityInBytes)
Given the current capacity of the write buffer, supply how many items to request next from the associated
PublisherSource.Subscription . |
void onItemWrite(java.lang.Object written, long writeBufferCapacityBeforeWrite, long writeBufferCapacityAfterWrite)
Write buffer capacity may not correctly reflect size of the object written. Hence capacity before may not necessarily be more than capacity after write.
written
- Item that was written.writeBufferCapacityBeforeWrite
- Capacity of the write buffer before this item was written.writeBufferCapacityAfterWrite
- Capacity of the write buffer after this item was written.long requestNFor(long writeBufferCapacityInBytes)
PublisherSource.Subscription
.
This method is invoked every time there could be a need to request more items from the write
Publisher
.
This means that the supplied writeBufferCapacityInBytes
may include the capacity for which we have
already requested the write Publisher
. For suppliers that must only request more when there is an
increase in capacity, use OverlappingCapacityAwareSupplier
.
writeBufferCapacityInBytes
- Current write buffer capacity. This will always be non-negative and will
be 0 if buffer is full.PublisherSource.Subscription
.
Implementation may assume that whatever is retuned here is sent as-is to the associated PublisherSource.Subscription
.OverlappingCapacityAwareSupplier
static NettyConnection.RequestNSupplier newDefaultSupplier()
NettyConnection.RequestNSupplier
.NettyConnection.RequestNSupplier
.