Class BlockingMultiObserver<T>
java.lang.Object
java.util.concurrent.CountDownLatch
io.reactivex.rxjava3.internal.observers.BlockingMultiObserver<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
CompletableObserver, MaybeObserver<T>, SingleObserver<T>
public final class BlockingMultiObserver<T>
extends CountDownLatch
implements SingleObserver<T>, CompletableObserver, MaybeObserver<T>
A combined Observer that awaits the success or error signal via a CountDownLatch.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanblockingAwait(long timeout, TimeUnit unit) Block until the observer terminates and return true; return false if the wait times out.voidblockingConsume(Consumer<? super T> onSuccess, Consumer<? super Throwable> onError, Action onComplete) Blocks until the source completes and calls the appropriate callback.Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (null if none).blockingGet(T defaultValue) Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (the defaultValue if none).(package private) voiddispose()voidCalled once the deferred computation completes normally.voidNotifies theSingleObserverthat theSinglehas experienced an error condition.voidProvides theSingleObserverwith the means of cancelling (disposing) the connection (channel) with the Single in both synchronous (from withinonSubscribe(Disposable)itself) and asynchronous manner.voidNotifies theSingleObserverwith a single item and that theSinglehas finished sending push-based notifications.
-
Field Details
-
value
T value -
error
Throwable error -
upstream
Disposable upstream -
cancelled
volatile boolean cancelled
-
-
Constructor Details
-
BlockingMultiObserver
public BlockingMultiObserver()
-
-
Method Details
-
dispose
void dispose() -
onSubscribe
Description copied from interface:SingleObserverProvides theSingleObserverwith the means of cancelling (disposing) the connection (channel) with the Single in both synchronous (from withinonSubscribe(Disposable)itself) and asynchronous manner.- Specified by:
onSubscribein interfaceCompletableObserver- Specified by:
onSubscribein interfaceMaybeObserver<T>- Specified by:
onSubscribein interfaceSingleObserver<T>- Parameters:
d- the Disposable instance whoseDisposable.dispose()can be called anytime to cancel the connection
-
onSuccess
Description copied from interface:SingleObserverNotifies theSingleObserverwith a single item and that theSinglehas finished sending push-based notifications.The
Singlewill not call this method if it callsSingleObserver.onError(Throwable).- Specified by:
onSuccessin interfaceMaybeObserver<T>- Specified by:
onSuccessin interfaceSingleObserver<T>- Parameters:
value- the item emitted by theSingle
-
onError
Description copied from interface:SingleObserverNotifies theSingleObserverthat theSinglehas experienced an error condition.If the
Singlecalls this method, it will not thereafter callSingleObserver.onSuccess(T).- Specified by:
onErrorin interfaceCompletableObserver- Specified by:
onErrorin interfaceMaybeObserver<T>- Specified by:
onErrorin interfaceSingleObserver<T>- Parameters:
e- the exception encountered by theSingle
-
onComplete
public void onComplete()Description copied from interface:CompletableObserverCalled once the deferred computation completes normally.- Specified by:
onCompletein interfaceCompletableObserver- Specified by:
onCompletein interfaceMaybeObserver<T>
-
blockingGet
Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (null if none).- Returns:
- the value received or null if no value received
-
blockingGet
Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (the defaultValue if none).- Parameters:
defaultValue- the default value to return if no value was received- Returns:
- the value received or defaultValue if no value received
-
blockingAwait
Block until the observer terminates and return true; return false if the wait times out.- Parameters:
timeout- the timeout valueunit- the time unit- Returns:
- true if the observer terminated in time, false otherwise
-
blockingConsume
-