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>
,Serializable
- Enclosing class:
ObservableCreate<T>
static final class ObservableCreate.SerializedEmitter<T>
extends AtomicInteger
implements ObservableEmitter<T>
Serializes calls to onNext, onError and onComplete.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
(package private) final ObservableEmitter
<T> (package private) final AtomicThrowable
(package private) final SpscLinkedArrayQueue
<T> private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
drain()
(package private) void
boolean
Returns true if the downstream disposed the sequence or the emitter was terminated viaEmitter.onError(Throwable)
,Emitter.onComplete()
or a successfulObservableEmitter.tryOnError(Throwable)
.void
Signal a completion.void
Signal aThrowable
exception.void
Signal a normal value.Ensures that calls toonNext
,onError
andonComplete
are properly serialized.void
Sets aCancellable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.void
Sets aDisposable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.toString()
boolean
Attempts to emit the specifiedThrowable
error 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
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
emitter
-
errors
-
queue
-
done
volatile boolean done
-
-
Constructor Details
-
SerializedEmitter
SerializedEmitter(ObservableEmitter<T> emitter)
-
-
Method Details
-
onNext
Description copied from interface:Emitter
Signal a normal value. -
onError
Description copied from interface:Emitter
Signal aThrowable
exception. -
tryOnError
Description copied from interface:ObservableEmitter
Attempts to emit the specifiedThrowable
error 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.onError
is not called if the error could not be delivered.History: 2.1.1 - experimental
- Specified by:
tryOnError
in interfaceObservableEmitter<T>
- Parameters:
t
- theThrowable
error 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:Emitter
Signal a completion.- Specified by:
onComplete
in interfaceEmitter<T>
-
drain
void drain() -
drainLoop
void drainLoop() -
setDisposable
Description copied from interface:ObservableEmitter
Sets aDisposable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setDisposable
in interfaceObservableEmitter<T>
- Parameters:
d
- theDisposable
,null
is allowed
-
setCancellable
Description copied from interface:ObservableEmitter
Sets aCancellable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setCancellable
in interfaceObservableEmitter<T>
- Parameters:
c
- theCancellable
resource,null
is allowed
-
isDisposed
public boolean isDisposed()Description copied from interface:ObservableEmitter
Returns 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:
isDisposed
in interfaceObservableEmitter<T>
- Returns:
- true if the downstream disposed the sequence or the emitter was terminated
-
serialize
Description copied from interface:ObservableEmitter
Ensures that calls toonNext
,onError
andonComplete
are properly serialized.- Specified by:
serialize
in interfaceObservableEmitter<T>
- Returns:
- the serialized
ObservableEmitter
-
toString
- Overrides:
toString
in classAtomicInteger
-