public class Subscriptions extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Subscriptions.CancelledSubscriber<X> |
static class |
Subscriptions.DeferredSubscription |
static class |
Subscriptions.EmptySubscription |
Modifier and Type | Field and Description |
---|---|
static Subscriptions.EmptySubscription |
CANCELLED
This instance must not be shared.
|
static Throwable |
TERMINATED |
Modifier and Type | Method and Description |
---|---|
static long |
add(AtomicLong requested,
long requests)
Atomically adds the positive value n to the requested value in the AtomicLong and
caps the result at Long.MAX_VALUE and returns the previous value.
|
static long |
add(long a,
long b)
Adds two long values and caps the sum at Long.MAX_VALUE.
|
static boolean |
addFailure(AtomicReference<Throwable> failures,
Throwable failure) |
static void |
cancel(AtomicReference<org.reactivestreams.Subscription> reference) |
static void |
complete(org.reactivestreams.Subscriber<?> subscriber)
Invokes
onSubscribe on the given Subscriber with the cancelled subscription instance
followed immediately by a call to onComplete . |
static void |
deferredRequest(AtomicReference<org.reactivestreams.Subscription> field,
AtomicLong requested,
long requests)
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 org.reactivestreams.Subscription |
empty() |
static void |
fail(org.reactivestreams.Subscriber<?> subscriber,
Throwable failure)
Invokes
onSubscribe on the given Subscriber with the cancelled subscription instance
followed immediately by a call to onError with the given failure. |
static void |
fail(org.reactivestreams.Subscriber<?> subscriber,
Throwable failure,
org.reactivestreams.Publisher<?> upstream) |
static IllegalArgumentException |
getInvalidRequestException() |
static Throwable |
markFailureAsTerminated(AtomicReference<Throwable> failures) |
static long |
multiply(long n,
long times)
Cap a multiplication to Long.MAX_VALUE
|
static long |
produced(AtomicLong requested,
long amount)
Concurrent subtraction bound to 0, mostly used to decrement a request tracker by
the amount produced by the operator.
|
static <T> io.smallrye.mutiny.helpers.Subscriptions.SingleItemSubscription<T> |
single(org.reactivestreams.Subscriber<T> downstream,
T item) |
static long |
subOrZero(long a,
long b)
Cap a subtraction to 0
|
static long |
subtract(AtomicLong requested,
long emitted)
Atomically subtract the given number (positive, not validated) from the target field unless it contains Long.MAX_VALUE.
|
static Throwable |
terminate(AtomicReference<Throwable> failure) |
static void |
terminateAndPropagate(AtomicReference<Throwable> failures,
org.reactivestreams.Subscriber<?> subscriber) |
static int |
unboundedOrLimit(int prefetch) |
static long |
unboundedOrMaxConcurrency(int concurrency) |
public static final Throwable TERMINATED
public static final Subscriptions.EmptySubscription CANCELLED
Subscription.cancel()
is a no-op.public static IllegalArgumentException getInvalidRequestException()
public static org.reactivestreams.Subscription empty()
public static void complete(org.reactivestreams.Subscriber<?> subscriber)
onSubscribe
on the given Subscriber
with the cancelled subscription instance
followed immediately by a call to onComplete
.subscriber
- the subscriber, must not be null
public static void fail(org.reactivestreams.Subscriber<?> subscriber, Throwable failure)
onSubscribe
on the given Subscriber
with the cancelled subscription instance
followed immediately by a call to onError
with the given failure.subscriber
- the subscriber, must not be null
failure
- the failure, must not be null
public static void fail(org.reactivestreams.Subscriber<?> subscriber, Throwable failure, org.reactivestreams.Publisher<?> upstream)
public static long add(long a, long b)
a
- the first valueb
- the second valuepublic static long add(AtomicLong requested, long requests)
requested
- the AtomicLong holding the current requested valuerequests
- the value to add, must be positive (not verified)public static long subtract(AtomicLong requested, long emitted)
requested
- the target field holding the current requested amountemitted
- the produced element count, positive (not validated)public static int unboundedOrLimit(int prefetch)
public static long unboundedOrMaxConcurrency(int concurrency)
public static boolean addFailure(AtomicReference<Throwable> failures, Throwable failure)
public static void cancel(AtomicReference<org.reactivestreams.Subscription> reference)
public static Throwable markFailureAsTerminated(AtomicReference<Throwable> failures)
public static void terminateAndPropagate(AtomicReference<Throwable> failures, org.reactivestreams.Subscriber<?> subscriber)
public static long multiply(long n, long times)
n
- left operandtimes
- right operandpublic static void deferredRequest(AtomicReference<org.reactivestreams.Subscription> field, AtomicLong requested, long requests)
field
- the target field that may already contain a Subscriptionrequested
- the current requested amountrequests
- the request amount, positive (verified)public static Throwable terminate(AtomicReference<Throwable> failure)
public static long produced(AtomicLong requested, long amount)
requested
- the atomic long keeping track of requestsamount
- delta to subtractpublic static long subOrZero(long a, long b)
a
- left operandb
- right operandpublic static <T> io.smallrye.mutiny.helpers.Subscriptions.SingleItemSubscription<T> single(org.reactivestreams.Subscriber<T> downstream, T item)
Copyright © 2019–2020 SmallRye. All rights reserved.