Class AsyncSubscription
java.lang.Object
java.lang.Number
java.util.concurrent.atomic.AtomicLong
io.reactivex.rxjava3.internal.subscriptions.AsyncSubscription
- All Implemented Interfaces:
Disposable,Serializable,org.reactivestreams.Subscription
public final class AsyncSubscription
extends AtomicLong
implements org.reactivestreams.Subscription, Disposable
A subscription implementation that arbitrates exactly one other Subscription and can
hold a single disposable resource.
All methods are thread-safe.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final AtomicReference<org.reactivestreams.Subscription> (package private) final AtomicReference<Disposable> private static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()voiddispose()Dispose the resource, the operation should be idempotent.booleanReturns true if this resource has been disposed.booleanReplaces the currently held resource with the given new one without disposing the old.voidrequest(long n) booleanSets a new resource and disposes the currently held resource.voidsetSubscription(org.reactivestreams.Subscription s) Sets the given subscription if there isn't any subscription held.Methods inherited from class java.util.concurrent.atomic.AtomicLong
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatileMethods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
actual
-
resource
-
-
Constructor Details
-
AsyncSubscription
public AsyncSubscription() -
AsyncSubscription
-
-
Method Details
-
request
public void request(long n) - Specified by:
requestin interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-
dispose
public void dispose()Description copied from interface:DisposableDispose the resource, the operation should be idempotent.- Specified by:
disposein interfaceDisposable
-
isDisposed
public 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
-
setResource
Sets a new resource and disposes the currently held resource.- Parameters:
r- the new resource to set- Returns:
- false if this AsyncSubscription has been cancelled/disposed
- See Also:
-
replaceResource
Replaces the currently held resource with the given new one without disposing the old.- Parameters:
r- the new resource to set- Returns:
- false if this AsyncSubscription has been cancelled/disposed
-
setSubscription
public void setSubscription(org.reactivestreams.Subscription s) Sets the given subscription if there isn't any subscription held.- Parameters:
s- the first and only subscription to set
-