Class FlowableCreate.SerializedEmitter<T>
- java.lang.Object
-
- java.lang.Number
-
- java.util.concurrent.atomic.AtomicInteger
-
- io.reactivex.rxjava3.internal.operators.flowable.FlowableCreate.SerializedEmitter<T>
-
- Type Parameters:
T
- the value type
- All Implemented Interfaces:
Emitter<T>
,FlowableEmitter<T>
,java.io.Serializable
- Enclosing class:
- FlowableCreate<T>
static final class FlowableCreate.SerializedEmitter<T> extends java.util.concurrent.atomic.AtomicInteger implements FlowableEmitter<T>
Serializes calls to onNext, onError and onComplete.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
done
(package private) FlowableCreate.BaseEmitter<T>
emitter
(package private) AtomicThrowable
errors
(package private) SimplePlainQueue<T>
queue
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description SerializedEmitter(FlowableCreate.BaseEmitter<T> emitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
drain()
(package private) void
drainLoop()
boolean
isCancelled()
Returns true if the downstream cancelled the sequence or the emitter was terminated viaEmitter.onError(Throwable)
,Emitter.onComplete()
or a successfulFlowableEmitter.tryOnError(Throwable)
.void
onComplete()
Signal a completion.void
onError(java.lang.Throwable t)
Signal aThrowable
exception.void
onNext(T t)
Signal a normal value.long
requested()
The current outstanding request amount.FlowableEmitter<T>
serialize()
Ensures that calls toonNext
,onError
andonComplete
are properly serialized.void
setCancellable(Cancellable c)
Sets aCancellable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.void
setDisposable(Disposable d)
Sets a Disposable on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.java.lang.String
toString()
boolean
tryOnError(java.lang.Throwable t)
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
emitter
final FlowableCreate.BaseEmitter<T> emitter
-
errors
final AtomicThrowable errors
-
queue
final SimplePlainQueue<T> queue
-
done
volatile boolean done
-
-
Constructor Detail
-
SerializedEmitter
SerializedEmitter(FlowableCreate.BaseEmitter<T> emitter)
-
-
Method Detail
-
onError
public void onError(java.lang.Throwable t)
Description copied from interface:Emitter
Signal aThrowable
exception.
-
tryOnError
public boolean tryOnError(java.lang.Throwable t)
Description copied from interface:FlowableEmitter
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 interfaceFlowableEmitter<T>
- Parameters:
t
- the throwable 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
public void setDisposable(Disposable d)
Description copied from interface:FlowableEmitter
Sets a Disposable on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setDisposable
in interfaceFlowableEmitter<T>
- Parameters:
d
- the disposable,null
is allowed
-
setCancellable
public void setCancellable(Cancellable c)
Description copied from interface:FlowableEmitter
Sets aCancellable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setCancellable
in interfaceFlowableEmitter<T>
- Parameters:
c
- theCancellable
resource,null
is allowed
-
requested
public long requested()
Description copied from interface:FlowableEmitter
The current outstanding request amount.This method is thread-safe.
- Specified by:
requested
in interfaceFlowableEmitter<T>
- Returns:
- the current outstanding request amount
-
isCancelled
public boolean isCancelled()
Description copied from interface:FlowableEmitter
Returns true if the downstream cancelled the sequence or the emitter was terminated viaEmitter.onError(Throwable)
,Emitter.onComplete()
or a successfulFlowableEmitter.tryOnError(Throwable)
.This method is thread-safe.
- Specified by:
isCancelled
in interfaceFlowableEmitter<T>
- Returns:
- true if the downstream cancelled the sequence or the emitter was terminated
-
serialize
public FlowableEmitter<T> serialize()
Description copied from interface:FlowableEmitter
Ensures that calls toonNext
,onError
andonComplete
are properly serialized.- Specified by:
serialize
in interfaceFlowableEmitter<T>
- Returns:
- the serialized
FlowableEmitter
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.concurrent.atomic.AtomicInteger
-
-