Class SingleThreadedBufferingSubscriber<T>
- java.lang.Object
-
- io.micronaut.core.async.subscriber.SingleThreadedBufferingSubscriber<T>
-
- Type Parameters:
T
- The type
- All Implemented Interfaces:
Completable
,Emitter<T>
,org.reactivestreams.Subscriber<T>
- Direct Known Subclasses:
SingleThreadedBufferingProcessor
public abstract class SingleThreadedBufferingSubscriber<T> extends java.lang.Object implements org.reactivestreams.Subscriber<T>, Emitter<T>
ASubscriber
designed to be used by a single thread that buffers incoming data for the purposes of managing back pressure.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SingleThreadedBufferingSubscriber.BackPressureState
Back pressure state.protected class
SingleThreadedBufferingSubscriber.DownstreamSubscription
A downstream subscription.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Queue<T>
upstreamBuffer
protected long
upstreamDemand
protected SingleThreadedBufferingSubscriber.BackPressureState
upstreamState
protected org.reactivestreams.Subscription
upstreamSubscription
-
Constructor Summary
Constructors Constructor Description SingleThreadedBufferingSubscriber()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
doOnComplete()
ImplementSubscriber.onComplete()
.protected abstract void
doOnError(java.lang.Throwable t)
ImplementSubscriber.onError(Throwable)
.protected abstract void
doOnNext(T message)
ImplementSubscriber.onNext(Object)
.protected abstract void
doOnSubscribe(org.reactivestreams.Subscription subscription)
ImplementSubscriber.onSubscribe(Subscription)
.protected org.reactivestreams.Subscription
newDownstreamSubscription()
void
onComplete()
* Successful terminal state.void
onError(java.lang.Throwable t)
Failed terminal state.void
onNext(T message)
Data notification sent by thePublisher
in response to requests toSubscription.request(long)
.void
onSubscribe(org.reactivestreams.Subscription subscription)
protected void
provideDownstreamSubscription(org.reactivestreams.Subscriber subscriber)
-
-
-
Field Detail
-
upstreamBuffer
protected final java.util.Queue<T> upstreamBuffer
-
upstreamState
protected SingleThreadedBufferingSubscriber.BackPressureState upstreamState
-
upstreamDemand
protected long upstreamDemand
-
upstreamSubscription
protected org.reactivestreams.Subscription upstreamSubscription
-
-
Method Detail
-
onSubscribe
public final void onSubscribe(org.reactivestreams.Subscription subscription)
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public final void onComplete()
Description copied from interface:Completable
* Successful terminal state. To be called when the operation is complete.- Specified by:
onComplete
in interfaceCompletable
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
- See Also:
Subscriber.onComplete()
-
onNext
public final void onNext(T message)
Description copied from interface:Emitter
Data notification sent by thePublisher
in response to requests toSubscription.request(long)
.
-
onError
public final void onError(java.lang.Throwable t)
Description copied from interface:Emitter
Failed terminal state.No further events will be sent even if
Subscription.request(long)
is invoked again.
-
doOnSubscribe
protected abstract void doOnSubscribe(org.reactivestreams.Subscription subscription)
ImplementSubscriber.onSubscribe(Subscription)
.- Parameters:
subscription
- The subscription
-
doOnNext
protected abstract void doOnNext(T message)
ImplementSubscriber.onNext(Object)
.- Parameters:
message
- The message
-
doOnError
protected abstract void doOnError(java.lang.Throwable t)
ImplementSubscriber.onError(Throwable)
.- Parameters:
t
- The throwable
-
doOnComplete
protected abstract void doOnComplete()
ImplementSubscriber.onComplete()
.
-
provideDownstreamSubscription
protected void provideDownstreamSubscription(org.reactivestreams.Subscriber subscriber)
- Parameters:
subscriber
- The subscriber
-
newDownstreamSubscription
protected org.reactivestreams.Subscription newDownstreamSubscription()
- Returns:
- The subscription
-
-