public class ByteBufferStoringSubscriber extends Object implements org.reactivestreams.Subscriber<ByteBuffer>
Subscriber that stores ByteBuffer events it receives for retrieval.
Stored bytes can be read via transferTo(ByteBuffer).
| Modifier and Type | Class and Description |
|---|---|
static class |
ByteBufferStoringSubscriber.TransferResult
The result of
transferTo(ByteBuffer). |
| Constructor and Description |
|---|
ByteBufferStoringSubscriber(long minimumBytesBuffered)
Create a subscriber that stores at least
minimumBytesBuffered in memory for retrieval. |
| Modifier and Type | Method and Description |
|---|---|
ByteBufferStoringSubscriber.TransferResult |
blockingTransferTo(ByteBuffer out)
Like
transferTo(ByteBuffer), but blocks until some data has been written. |
void |
onComplete() |
void |
onError(Throwable t) |
void |
onNext(ByteBuffer byteBuffer) |
void |
onSubscribe(org.reactivestreams.Subscription s) |
ByteBufferStoringSubscriber.TransferResult |
transferTo(ByteBuffer out)
Transfer the data stored by this subscriber into the provided byte buffer.
|
public ByteBufferStoringSubscriber(long minimumBytesBuffered)
minimumBytesBuffered in memory for retrieval.public ByteBufferStoringSubscriber.TransferResult transferTo(ByteBuffer out)
If the data stored by this subscriber exceeds out's limit, then out will be filled. If the data
stored by this subscriber is less than out's limit, then all stored data will be written to out.
If onError(Throwable) was called on this subscriber, as much data as is available will be transferred into
out before the provided exception is thrown (as a RuntimeException).
If onComplete() was called on this subscriber, as much data as is available will be transferred into
out, and this will return ByteBufferStoringSubscriber.TransferResult.END_OF_STREAM.
Note: This method MUST NOT be called concurrently with itself or blockingTransferTo(ByteBuffer). Other methods
on this class may be called concurrently with this one. This MUST NOT be called before
onSubscribe(Subscription) has returned.
public ByteBufferStoringSubscriber.TransferResult blockingTransferTo(ByteBuffer out)
transferTo(ByteBuffer), but blocks until some data has been written.
Note: This method MUST NOT be called concurrently with itself or transferTo(ByteBuffer). Other methods
on this class may be called concurrently with this one.
public void onSubscribe(org.reactivestreams.Subscription s)
onSubscribe in interface org.reactivestreams.Subscriber<ByteBuffer>public void onNext(ByteBuffer byteBuffer)
onNext in interface org.reactivestreams.Subscriber<ByteBuffer>public void onError(Throwable t)
onError in interface org.reactivestreams.Subscriber<ByteBuffer>public void onComplete()
onComplete in interface org.reactivestreams.Subscriber<ByteBuffer>Copyright © 2023. All rights reserved.