Class BlockingBaseObserver<T>
java.lang.Object
java.util.concurrent.CountDownLatch
io.reactivex.rxjava3.internal.observers.BlockingBaseObserver<T>
- All Implemented Interfaces:
Observer<T>,Disposable
- Direct Known Subclasses:
BlockingFirstObserver,BlockingLastObserver
public abstract class BlockingBaseObserver<T>
extends CountDownLatch
implements Observer<T>, Disposable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal TBlock until the first value arrives and return it, otherwise return null for an empty source and rethrow any exception.final voiddispose()Dispose the resource, the operation should be idempotent.final booleanReturns true if this resource has been disposed.final voidNotifies theObserverthat theObservablehas finished sending push-based notifications.final voidProvides theObserverwith the means of cancelling (disposing) the connection (channel) with theObservablein both synchronous (from withinObserver.onNext(Object)) and asynchronous manner.Methods inherited from class java.util.concurrent.CountDownLatch
await, await, countDown, getCount, toString
-
Field Details
-
value
T value -
error
Throwable error -
upstream
Disposable upstream -
cancelled
volatile boolean cancelled
-
-
Constructor Details
-
BlockingBaseObserver
public BlockingBaseObserver()
-
-
Method Details
-
onSubscribe
Description copied from interface:ObserverProvides theObserverwith the means of cancelling (disposing) the connection (channel) with theObservablein both synchronous (from withinObserver.onNext(Object)) and asynchronous manner.- Specified by:
onSubscribein interfaceObserver<T>- Parameters:
d- theDisposableinstance whoseDisposable.dispose()can be called anytime to cancel the connection
-
onComplete
public final void onComplete()Description copied from interface:ObserverNotifies theObserverthat theObservablehas finished sending push-based notifications.The
Observablewill not call this method if it callsObserver.onError(java.lang.Throwable).- Specified by:
onCompletein interfaceObserver<T>
-
dispose
public final void dispose()Description copied from interface:DisposableDispose the resource, the operation should be idempotent.- Specified by:
disposein interfaceDisposable
-
isDisposed
public final boolean isDisposed()Description copied from interface:DisposableReturns true if this resource has been disposed.- Specified by:
isDisposedin interfaceDisposable- Returns:
- true if this resource has been disposed
-
blockingGet
Block until the first value arrives and return it, otherwise return null for an empty source and rethrow any exception.- Returns:
- the first value or null if the source is empty
-