public class SubscriptionWithContext<C> extends Object implements org.reactivestreams.Subscription
Subscription
with a typed stateful context. Some request utils are also provided to read pending demand and
request relatively to it.Modifier and Type | Field and Description |
---|---|
protected C |
context |
protected static AtomicLongFieldUpdater<SubscriptionWithContext> |
PENDING_UPDATER |
protected org.reactivestreams.Subscription |
subscription |
protected static AtomicIntegerFieldUpdater<SubscriptionWithContext> |
TERMINATED_UPDATER |
Modifier | Constructor and Description |
---|---|
protected |
SubscriptionWithContext(C context,
org.reactivestreams.Subscription subscription) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
C |
context()
The stateful context C
|
static <C> SubscriptionWithContext<C> |
create(org.reactivestreams.Subscription subscription,
C context)
Attach a given arbitrary context (stateful information) to a
Subscription , all Subscription methods
will delegate properly. |
boolean |
isCancelled() |
void |
request(long n) |
protected static final AtomicLongFieldUpdater<SubscriptionWithContext> PENDING_UPDATER
protected static final AtomicIntegerFieldUpdater<SubscriptionWithContext> TERMINATED_UPDATER
protected final C context
protected final org.reactivestreams.Subscription subscription
protected SubscriptionWithContext(C context, org.reactivestreams.Subscription subscription)
public static <C> SubscriptionWithContext<C> create(org.reactivestreams.Subscription subscription, C context)
Subscription
, all Subscription methods
will delegate properly.C
- Type of attached stateful contextsubscription
- the delegate subscription to invoke on request/cancelcontext
- the contextual state of any type to bind for later usepublic C context()
public void request(long n)
request
in interface org.reactivestreams.Subscription
public void cancel()
cancel
in interface org.reactivestreams.Subscription
public boolean isCancelled()
Copyright © 2017. All rights reserved.