Class ObservableCreate.SerializedEmitter<T>
- java.lang.Object
-
- java.lang.Number
-
- java.util.concurrent.atomic.AtomicInteger
-
- io.reactivex.rxjava3.internal.operators.observable.ObservableCreate.SerializedEmitter<T>
-
- Type Parameters:
T- the value type
- All Implemented Interfaces:
Emitter<T>,ObservableEmitter<T>,java.io.Serializable
- Enclosing class:
- ObservableCreate<T>
static final class ObservableCreate.SerializedEmitter<T> extends java.util.concurrent.atomic.AtomicInteger implements ObservableEmitter<T>
Serializes calls to onNext, onError and onComplete.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleandone(package private) ObservableEmitter<T>emitter(package private) AtomicThrowableerrors(package private) SpscLinkedArrayQueue<T>queueprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description SerializedEmitter(ObservableEmitter<T> emitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voiddrain()(package private) voiddrainLoop()booleanisDisposed()Returns true if the downstream disposed the sequence or the emitter was terminated viaEmitter.onError(Throwable),Emitter.onComplete()or a successfulObservableEmitter.tryOnError(Throwable).voidonComplete()Signal a completion.voidonError(java.lang.Throwable t)Signal aThrowableexception.voidonNext(T t)Signal a normal value.ObservableEmitter<T>serialize()Ensures that calls toonNext,onErrorandonCompleteare properly serialized.voidsetCancellable(Cancellable c)Sets aCancellableon this emitter; any previousDisposableorCancellablewill be disposed/cancelled.voidsetDisposable(Disposable d)Sets aDisposableon this emitter; any previousDisposableorCancellablewill be disposed/cancelled.java.lang.StringtoString()booleantryOnError(java.lang.Throwable t)Attempts to emit the specifiedThrowableerror if the downstream hasn't cancelled the sequence or is otherwise terminated, returning false if the emission is not allowed to happen due to lifecycle restrictions.-
Methods inherited from class java.util.concurrent.atomic.AtomicInteger
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
emitter
final ObservableEmitter<T> emitter
-
errors
final AtomicThrowable errors
-
queue
final SpscLinkedArrayQueue<T> queue
-
done
volatile boolean done
-
-
Constructor Detail
-
SerializedEmitter
SerializedEmitter(ObservableEmitter<T> emitter)
-
-
Method Detail
-
onError
public void onError(java.lang.Throwable t)
Description copied from interface:EmitterSignal aThrowableexception.
-
tryOnError
public boolean tryOnError(java.lang.Throwable t)
Description copied from interface:ObservableEmitterAttempts to emit the specifiedThrowableerror if the downstream hasn't cancelled the sequence or is otherwise terminated, returning false if the emission is not allowed to happen due to lifecycle restrictions.Unlike
Emitter.onError(Throwable), theRxjavaPlugins.onErroris not called if the error could not be delivered.History: 2.1.1 - experimental
- Specified by:
tryOnErrorin interfaceObservableEmitter<T>- Parameters:
t- theThrowableerror to signal if possible- Returns:
- true if successful, false if the downstream is not able to accept further events
-
onComplete
public void onComplete()
Description copied from interface:EmitterSignal a completion.- Specified by:
onCompletein interfaceEmitter<T>
-
drain
void drain()
-
drainLoop
void drainLoop()
-
setDisposable
public void setDisposable(Disposable d)
Description copied from interface:ObservableEmitterSets aDisposableon this emitter; any previousDisposableorCancellablewill be disposed/cancelled.This method is thread-safe.
- Specified by:
setDisposablein interfaceObservableEmitter<T>- Parameters:
d- theDisposable,nullis allowed
-
setCancellable
public void setCancellable(Cancellable c)
Description copied from interface:ObservableEmitterSets aCancellableon this emitter; any previousDisposableorCancellablewill be disposed/cancelled.This method is thread-safe.
- Specified by:
setCancellablein interfaceObservableEmitter<T>- Parameters:
c- theCancellableresource,nullis allowed
-
isDisposed
public boolean isDisposed()
Description copied from interface:ObservableEmitterReturns true if the downstream disposed the sequence or the emitter was terminated viaEmitter.onError(Throwable),Emitter.onComplete()or a successfulObservableEmitter.tryOnError(Throwable).This method is thread-safe.
- Specified by:
isDisposedin interfaceObservableEmitter<T>- Returns:
- true if the downstream disposed the sequence or the emitter was terminated
-
serialize
public ObservableEmitter<T> serialize()
Description copied from interface:ObservableEmitterEnsures that calls toonNext,onErrorandonCompleteare properly serialized.- Specified by:
serializein interfaceObservableEmitter<T>- Returns:
- the serialized
ObservableEmitter
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.concurrent.atomic.AtomicInteger
-
-