Package org.apache.hc.core5.reactive
Class ReactiveDataProducer
- java.lang.Object
-
- org.apache.hc.core5.reactive.ReactiveDataProducer
-
- All Implemented Interfaces:
AsyncDataProducer
,ResourceHolder
,org.reactivestreams.Subscriber<java.nio.ByteBuffer>
@Contract(threading=SAFE) final class ReactiveDataProducer extends java.lang.Object implements AsyncDataProducer, org.reactivestreams.Subscriber<java.nio.ByteBuffer>
An asynchronous data producer that supports Reactive Streams.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFFER_WINDOW_SIZE
private java.util.ArrayDeque<java.nio.ByteBuffer>
buffers
private java.util.concurrent.atomic.AtomicBoolean
complete
private java.util.concurrent.atomic.AtomicReference<java.lang.Throwable>
exception
private org.reactivestreams.Publisher<java.nio.ByteBuffer>
publisher
private java.util.concurrent.atomic.AtomicReference<DataStreamChannel>
requestChannel
private java.util.concurrent.atomic.AtomicReference<org.reactivestreams.Subscription>
subscription
-
Constructor Summary
Constructors Constructor Description ReactiveDataProducer(org.reactivestreams.Publisher<java.nio.ByteBuffer> publisher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns the number of bytes immediately available for output.void
onComplete()
void
onError(java.lang.Throwable throwable)
void
onNext(java.nio.ByteBuffer byteBuffer)
void
onSubscribe(org.reactivestreams.Subscription subscription)
void
produce(DataStreamChannel channel)
Triggered to signal the ability of the underlying data channel to accept more data.void
releaseResources()
(package private) void
setChannel(DataStreamChannel channel)
private void
signalReadiness()
-
-
-
Field Detail
-
BUFFER_WINDOW_SIZE
private static final int BUFFER_WINDOW_SIZE
- See Also:
- Constant Field Values
-
requestChannel
private final java.util.concurrent.atomic.AtomicReference<DataStreamChannel> requestChannel
-
exception
private final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> exception
-
complete
private final java.util.concurrent.atomic.AtomicBoolean complete
-
publisher
private final org.reactivestreams.Publisher<java.nio.ByteBuffer> publisher
-
subscription
private final java.util.concurrent.atomic.AtomicReference<org.reactivestreams.Subscription> subscription
-
buffers
private final java.util.ArrayDeque<java.nio.ByteBuffer> buffers
-
-
Method Detail
-
setChannel
void setChannel(DataStreamChannel channel)
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription)
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<java.nio.ByteBuffer>
-
onNext
public void onNext(java.nio.ByteBuffer byteBuffer)
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<java.nio.ByteBuffer>
-
onError
public void onError(java.lang.Throwable throwable)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<java.nio.ByteBuffer>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<java.nio.ByteBuffer>
-
signalReadiness
private void signalReadiness()
-
available
public int available()
Description copied from interface:AsyncDataProducer
Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.- Specified by:
available
in interfaceAsyncDataProducer
- Returns:
- the number of bytes immediately available for output
-
produce
public void produce(DataStreamChannel channel) throws java.io.IOException
Description copied from interface:AsyncDataProducer
Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.- Specified by:
produce
in interfaceAsyncDataProducer
- Parameters:
channel
- the data channel capable to accepting more data.- Throws:
java.io.IOException
-
releaseResources
public void releaseResources()
- Specified by:
releaseResources
in interfaceResourceHolder
-
-