Class SingleCreate.Emitter<T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<Disposable>
-
- io.reactivex.rxjava3.internal.operators.single.SingleCreate.Emitter<T>
-
- All Implemented Interfaces:
SingleEmitter<T>
,Disposable
,java.io.Serializable
- Enclosing class:
- SingleCreate<T>
static final class SingleCreate.Emitter<T> extends java.util.concurrent.atomic.AtomicReference<Disposable> implements SingleEmitter<T>, Disposable
-
-
Field Summary
Fields Modifier and Type Field Description (package private) SingleObserver<? super T>
downstream
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description Emitter(SingleObserver<? super T> downstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Dispose the resource, the operation should be idempotent.boolean
isDisposed()
Returns true if the downstream disposed the sequence or the emitter was terminated viaSingleEmitter.onSuccess(Object)
,SingleEmitter.onError(Throwable)
, or a successfulSingleEmitter.tryOnError(Throwable)
.void
onError(java.lang.Throwable t)
Signal an exception.void
onSuccess(T value)
Signal a success value.void
setCancellable(Cancellable c)
Sets a Cancellable on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.void
setDisposable(Disposable d)
Sets aDisposable
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.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
downstream
final SingleObserver<? super T> downstream
-
-
Constructor Detail
-
Emitter
Emitter(SingleObserver<? super T> downstream)
-
-
Method Detail
-
onSuccess
public void onSuccess(T value)
Description copied from interface:SingleEmitter
Signal a success value.- Specified by:
onSuccess
in interfaceSingleEmitter<T>
- Parameters:
value
- the value, not null
-
onError
public void onError(java.lang.Throwable t)
Description copied from interface:SingleEmitter
Signal an exception.- Specified by:
onError
in interfaceSingleEmitter<T>
- Parameters:
t
- the exception, notnull
-
tryOnError
public boolean tryOnError(java.lang.Throwable t)
Description copied from interface:SingleEmitter
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
SingleEmitter.onError(Throwable)
, theRxjavaPlugins.onError
is not called if the error could not be delivered.History: 2.1.1 - experimental
- Specified by:
tryOnError
in interfaceSingleEmitter<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
-
setDisposable
public void setDisposable(Disposable d)
Description copied from interface:SingleEmitter
Sets aDisposable
on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setDisposable
in interfaceSingleEmitter<T>
- Parameters:
d
- theDisposable
,null
is allowed
-
setCancellable
public void setCancellable(Cancellable c)
Description copied from interface:SingleEmitter
Sets a Cancellable on this emitter; any previousDisposable
orCancellable
will be disposed/cancelled.This method is thread-safe.
- Specified by:
setCancellable
in interfaceSingleEmitter<T>
- Parameters:
c
- theCancellable
resource,null
is allowed
-
dispose
public void dispose()
Description copied from interface:Disposable
Dispose the resource, the operation should be idempotent.- Specified by:
dispose
in interfaceDisposable
-
isDisposed
public boolean isDisposed()
Description copied from interface:SingleEmitter
Returns true if the downstream disposed the sequence or the emitter was terminated viaSingleEmitter.onSuccess(Object)
,SingleEmitter.onError(Throwable)
, or a successfulSingleEmitter.tryOnError(Throwable)
.This method is thread-safe.
- Specified by:
isDisposed
in interfaceDisposable
- Specified by:
isDisposed
in interfaceSingleEmitter<T>
- Returns:
- true if the downstream disposed the sequence or the emitter was terminated
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.concurrent.atomic.AtomicReference<Disposable>
-
-