Class ByteBufferStoringSubscriber
- All Implemented Interfaces:
org.reactivestreams.Subscriber<ByteBuffer>
Subscriber
that stores ByteBuffer
events it receives for retrieval.
Stored bytes can be read via transferTo(ByteBuffer)
.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionByteBufferStoringSubscriber
(long minimumBytesBuffered) Create a subscriber that stores at leastminimumBytesBuffered
in memory for retrieval. -
Method Summary
Modifier and TypeMethodDescriptionLiketransferTo(ByteBuffer)
, but blocks until some data has been written.void
void
void
onNext
(ByteBuffer byteBuffer) void
onSubscribe
(org.reactivestreams.Subscription s) transferTo
(ByteBuffer out) Transfer the data stored by this subscriber into the provided byte buffer.
-
Constructor Details
-
ByteBufferStoringSubscriber
public ByteBufferStoringSubscriber(long minimumBytesBuffered) Create a subscriber that stores at leastminimumBytesBuffered
in memory for retrieval.
-
-
Method Details
-
transferTo
Transfer the data stored by this subscriber into the provided byte buffer.If the data stored by this subscriber exceeds
out
'slimit
, thenout
will be filled. If the data stored by this subscriber is less thanout
'slimit
, then all stored data will be written toout
.If
onError(Throwable)
was called on this subscriber, as much data as is available will be transferred intoout
before the provided exception is thrown (as aRuntimeException
).If
onComplete()
was called on this subscriber, as much data as is available will be transferred intoout
, and this will returnByteBufferStoringSubscriber.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 beforeonSubscribe(Subscription)
has returned. -
blockingTransferTo
LiketransferTo(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. -
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s) - Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onNext
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onError
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-