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 T
Block until the first value arrives and return it, otherwise return null for an empty source and rethrow any exception.final void
dispose()
Dispose the resource, the operation should be idempotent.final boolean
Returns true if this resource has been disposed.final void
Notifies theObserver
that theObservable
has finished sending push-based notifications.final void
Provides theObserver
with the means of cancelling (disposing) the connection (channel) with theObservable
in 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:Observer
Provides theObserver
with the means of cancelling (disposing) the connection (channel) with theObservable
in both synchronous (from withinObserver.onNext(Object)
) and asynchronous manner.- Specified by:
onSubscribe
in interfaceObserver<T>
- Parameters:
d
- theDisposable
instance whoseDisposable.dispose()
can be called anytime to cancel the connection
-
onComplete
public final void onComplete()Description copied from interface:Observer
Notifies theObserver
that theObservable
has finished sending push-based notifications.The
Observable
will not call this method if it callsObserver.onError(java.lang.Throwable)
.- Specified by:
onComplete
in interfaceObserver<T>
-
dispose
public final void dispose()Description copied from interface:Disposable
Dispose the resource, the operation should be idempotent.- Specified by:
dispose
in interfaceDisposable
-
isDisposed
public final boolean isDisposed()Description copied from interface:Disposable
Returns true if this resource has been disposed.- Specified by:
isDisposed
in 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
-