public enum SubscriptionHelper extends Enum<SubscriptionHelper> implements org.reactivestreams.Subscription
Enum Constant and Description |
---|
CANCELLED
Represents a cancelled Subscription.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
static boolean |
cancel(AtomicReference<org.reactivestreams.Subscription> field)
Atomically swaps in the common cancelled subscription instance
and cancels the previous subscription if any.
|
static void |
deferredRequest(AtomicReference<org.reactivestreams.Subscription> field,
AtomicLong requested,
long n)
Atomically requests from the Subscription in the field if not null, otherwise accumulates
the request amount in the requested field to be requested once the field is set to non-null.
|
static boolean |
deferredSetOnce(AtomicReference<org.reactivestreams.Subscription> field,
AtomicLong requested,
org.reactivestreams.Subscription s)
Atomically sets the new Subscription on the field and requests any accumulated amount
from the requested field.
|
static boolean |
isCancelled(org.reactivestreams.Subscription s)
Check if the given subscription is the common cancelled subscription.
|
static boolean |
replace(AtomicReference<org.reactivestreams.Subscription> field,
org.reactivestreams.Subscription s)
Atomically sets the subscription on the field but does not
cancel the previous subscription.
|
static void |
reportMoreProduced(long n)
Reports to the plugin error handler that there were more values produced than requested, which
is a sign of internal backpressure handling bug.
|
static void |
reportSubscriptionSet()
Reports that the subscription is already set to the RxJavaPlugins error handler,
which is an indication of a onSubscribe management bug.
|
void |
request(long n) |
static boolean |
set(AtomicReference<org.reactivestreams.Subscription> field,
org.reactivestreams.Subscription s)
Atomically sets the subscription on the field and cancels the
previous subscription if any.
|
static boolean |
setOnce(AtomicReference<org.reactivestreams.Subscription> field,
org.reactivestreams.Subscription s)
Atomically sets the subscription on the field if it is still null.
|
static boolean |
setOnce(AtomicReference<org.reactivestreams.Subscription> field,
org.reactivestreams.Subscription s,
long request)
Atomically sets the subscription on the field if it is still null and issues a positive request
to the given
Subscription . |
static boolean |
validate(long n)
Validates that the n is positive.
|
static boolean |
validate(org.reactivestreams.Subscription current,
org.reactivestreams.Subscription next)
Verifies that current is null, next is not null, otherwise signals errors
to the RxJavaPlugins and returns false.
|
static SubscriptionHelper |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SubscriptionHelper[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SubscriptionHelper CANCELLED
Don't leak this instance!
public static SubscriptionHelper[] values()
for (SubscriptionHelper c : SubscriptionHelper.values()) System.out.println(c);
public static SubscriptionHelper valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic void request(long n)
request
in interface org.reactivestreams.Subscription
public void cancel()
cancel
in interface org.reactivestreams.Subscription
public static boolean validate(org.reactivestreams.Subscription current, org.reactivestreams.Subscription next)
current
- the current Subscription, expected to be nullnext
- the next Subscription, expected to be non-nullpublic static void reportSubscriptionSet()
public static boolean validate(long n)
n
- the request amountpublic static void reportMoreProduced(long n)
n
- the overproduction amountpublic static boolean isCancelled(org.reactivestreams.Subscription s)
s
- the subscription to checkpublic static boolean set(AtomicReference<org.reactivestreams.Subscription> field, org.reactivestreams.Subscription s)
field
- the target field to set the new subscription ons
- the new subscriptionCANCELLED
instance.replace(AtomicReference, Subscription)
public static boolean setOnce(AtomicReference<org.reactivestreams.Subscription> field, org.reactivestreams.Subscription s)
If the field is not null and doesn't contain the CANCELLED
instance, the reportSubscriptionSet()
is called.
field
- the target fields
- the new subscription to setpublic static boolean replace(AtomicReference<org.reactivestreams.Subscription> field, org.reactivestreams.Subscription s)
field
- the target field to set the new subscription ons
- the new subscriptionCANCELLED
instance.set(AtomicReference, Subscription)
public static boolean cancel(AtomicReference<org.reactivestreams.Subscription> field)
field
- the target field to dispose the contents ofpublic static boolean deferredSetOnce(AtomicReference<org.reactivestreams.Subscription> field, AtomicLong requested, org.reactivestreams.Subscription s)
field
- the target field for the new Subscriptionrequested
- the current requested amounts
- the new Subscription, not null (verified)public static void deferredRequest(AtomicReference<org.reactivestreams.Subscription> field, AtomicLong requested, long n)
field
- the target field that may already contain a Subscriptionrequested
- the current requested amountn
- the request amount, positive (verified)public static boolean setOnce(AtomicReference<org.reactivestreams.Subscription> field, org.reactivestreams.Subscription s, long request)
Subscription
.
If the field is not null and doesn't contain the CANCELLED
instance, the reportSubscriptionSet()
is called.
field
- the target fields
- the new subscription to setrequest
- the amount to request, positive (not verified)Copyright © 2018 JBoss by Red Hat. All rights reserved.