Class FutureSubscriber<T>
- java.lang.Object
-
- java.util.concurrent.CountDownLatch
-
- io.reactivex.rxjava3.internal.subscribers.FutureSubscriber<T>
-
- Type Parameters:
T
- the value type
- All Implemented Interfaces:
FlowableSubscriber<T>
,java.util.concurrent.Future<T>
,org.reactivestreams.Subscriber<T>
,org.reactivestreams.Subscription
public final class FutureSubscriber<T> extends java.util.concurrent.CountDownLatch implements FlowableSubscriber<T>, java.util.concurrent.Future<T>, org.reactivestreams.Subscription
A Subscriber + Future that expects exactly one upstream value and provides it via the (blocking) Future API.
-
-
Constructor Summary
Constructors Constructor Description FutureSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
boolean
cancel(boolean mayInterruptIfRunning)
T
get()
T
get(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
void
onComplete()
void
onError(java.lang.Throwable t)
void
onNext(T t)
void
onSubscribe(org.reactivestreams.Subscription s)
Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)
is established before callingSubscription.request(long)
.void
request(long n)
-
-
-
Field Detail
-
value
T value
-
error
java.lang.Throwable error
-
upstream
final java.util.concurrent.atomic.AtomicReference<org.reactivestreams.Subscription> upstream
-
-
Method Detail
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<T>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<T>
-
get
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<T>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public T get(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<T>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s)
Description copied from interface:FlowableSubscriber
Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)
is established before callingSubscription.request(long)
. In practice this means no initialization should happen after therequest()
call and additional behavior is thread safe in respect toonNext
.- Specified by:
onSubscribe
in interfaceFlowableSubscriber<T>
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
public void onError(java.lang.Throwable t)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
cancel
public void cancel()
- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-
request
public void request(long n)
- Specified by:
request
in interfaceorg.reactivestreams.Subscription
-
-