T
- the value typepublic final class ScalarSubscription<T> extends AtomicInteger implements QueueSubscription<T>
Constructor and Description |
---|
ScalarSubscription(org.reactivestreams.Subscriber<? super T> subscriber,
T value) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
void |
clear()
Removes all enqueued items from this queue.
|
boolean |
isCancelled()
Returns true if this Subscription was cancelled.
|
boolean |
isEmpty()
Returns true if the queue is empty.
|
boolean |
offer(T e)
Atomically enqueue a single.
|
boolean |
offer(T v1,
T v2)
Atomically enqueue two values.
|
T |
poll()
Tries to dequeue a value (non-null) or returns null if
the queue is empty.
|
void |
request(long n) |
int |
requestFusion(int mode)
Request a fusion mode from the upstream.
|
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSet
byteValue, shortValue
public void request(long n)
request
in interface org.reactivestreams.Subscription
public void cancel()
cancel
in interface org.reactivestreams.Subscription
public boolean isCancelled()
public boolean offer(T e)
SimpleQueue
offer
in interface SimpleQueue<T>
e
- the value to enqueue, not nullpublic boolean offer(T v1, T v2)
SimpleQueue
offer
in interface SimpleQueue<T>
v1
- the first value to enqueue, not nullv2
- the second value to enqueue, not null@Nullable public T poll()
SimpleQueue
If the producer uses SimpleQueue.offer(Object, Object)
and
when polling in pairs, if the first poll() returns a non-null
item, the second poll() is guaranteed to return a non-null item
as well.
poll
in interface SimpleQueue<T>
public boolean isEmpty()
SimpleQueue
Note however that due to potential fused functions in SimpleQueue.poll()
it is possible this method returns false but then poll() returns null
because the fused function swallowed the available item(s).
isEmpty
in interface SimpleQueue<T>
public void clear()
SimpleQueue
clear
in interface SimpleQueue<T>
public int requestFusion(int mode)
QueueFuseable
This should be called before onSubscribe
returns.
Calling this method multiple times or after onSubscribe
finished is not allowed
and may result in undefined behavior.
requestFusion
in interface QueueFuseable<T>
mode
- the requested fusion mode, allowed values are QueueFuseable.SYNC
, QueueFuseable.ASYNC
,
QueueFuseable.ANY
combined with QueueFuseable.BOUNDARY
(e.g., requestFusion(SYNC | BOUNDARY)
).QueueFuseable.NONE
, QueueFuseable.SYNC
, QueueFuseable.ASYNC
.Copyright © 2018 JBoss by Red Hat. All rights reserved.