Class SerializedMultiEmitter<T>
- java.lang.Object
-
- io.smallrye.mutiny.operators.multi.builders.SerializedMultiEmitter<T>
-
- Type Parameters:
T- the type of item
- All Implemented Interfaces:
MultiEmitter<T>,MultiSubscriber<T>,org.reactivestreams.Subscriber<T>
public class SerializedMultiEmitter<T> extends java.lang.Object implements MultiEmitter<T>, MultiSubscriber<T>
Serializes calls to onItem, onFailure and onCompletion and their Reactive Streams equivalent.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Emits acompletionevent downstream indicating that no more item will be sent.MultiEmitter<T>emit(T item)Emits anitemevent downstream.voidfail(java.lang.Throwable failure)Emits afailureevent downstream with the given exception.booleanisCancelled()voidonCompletion()Method called when the upstream emits acompletionterminal event.voidonFailure(java.lang.Throwable failure)Method called when the upstream emits afailureterminal event.voidonItem(T item)Method called when the upstream emits anitemevent, in response to to requests toSubscription.request(long).voidonSubscribe(org.reactivestreams.Subscription s)MultiEmitter<T>onTermination(java.lang.Runnable onTermination)Attaches a @{code termination} event handler invoked when the downstreamSubscriptionis cancelled, or when the emitter has emitted either acompletionorfailureevent.longrequested()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.smallrye.mutiny.subscription.MultiSubscriber
onComplete, onError, onNext
-
-
-
-
Method Detail
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s)
- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
onItem
public void onItem(T item)
Description copied from interface:MultiSubscriberMethod called when the upstream emits anitemevent, in response to to requests toSubscription.request(long).- Specified by:
onItemin interfaceMultiSubscriber<T>- Parameters:
item- the item, must not benull.
-
onFailure
public void onFailure(java.lang.Throwable failure)
Description copied from interface:MultiSubscriberMethod called when the upstream emits afailureterminal event.No further events will be sent even if
Subscription.request(long)is invoked again.- Specified by:
onFailurein interfaceMultiSubscriber<T>- Parameters:
failure- the failure, must not benull.
-
onCompletion
public void onCompletion()
Description copied from interface:MultiSubscriberMethod called when the upstream emits acompletionterminal event.No further events will be sent even if
Subscription.request(long)is invoked again.- Specified by:
onCompletionin interfaceMultiSubscriber<T>
-
emit
public MultiEmitter<T> emit(T item)
Description copied from interface:MultiEmitterEmits anitemevent downstream.Calling this method after a failure or a completion events has no effect.
- Specified by:
emitin interfaceMultiEmitter<T>- Parameters:
item- the item, must not benull- Returns:
- this emitter, so firing item events can be chained.
-
fail
public void fail(java.lang.Throwable failure)
Description copied from interface:MultiEmitterEmits afailureevent downstream with the given exception.Calling this method multiple times or after the
MultiEmitter.complete()method has no effect.- Specified by:
failin interfaceMultiEmitter<T>- Parameters:
failure- the exception, must not benull
-
complete
public void complete()
Description copied from interface:MultiEmitterEmits acompletionevent downstream indicating that no more item will be sent.Calling this method multiple times or after the
MultiEmitter.fail(Throwable)method has no effect.- Specified by:
completein interfaceMultiEmitter<T>
-
onTermination
public MultiEmitter<T> onTermination(java.lang.Runnable onTermination)
Description copied from interface:MultiEmitterAttaches a @{code termination} event handler invoked when the downstreamSubscriptionis cancelled, or when the emitter has emitted either acompletionorfailureevent.This method allows cleanup resources once the emitter can be disposed (has reached a terminal state).
If the registration of the
onTerminationcallback is done after the termination, it invokes the callback immediately.- Specified by:
onTerminationin interfaceMultiEmitter<T>- Parameters:
onTermination- the action to run on termination, must not benull- Returns:
- this emitter
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceMultiEmitter<T>- Returns:
trueif the downstream cancelled the stream or the emitter was terminated (with a completion or failure events).
-
requested
public long requested()
- Specified by:
requestedin interfaceMultiEmitter<T>- Returns:
- the current outstanding request amount.
-
-