T
- the value typepublic static final class ObservableScalarXMap.ScalarDisposable<T> extends AtomicInteger implements QueueDisposable<T>, Runnable
Constructor and Description |
---|
ScalarDisposable(Observer<? super T> observer,
T value) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all enqueued items from this queue.
|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
boolean |
isEmpty()
Returns true if the queue is empty.
|
boolean |
offer(T value)
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.
|
int |
requestFusion(int mode)
Request a fusion mode from the upstream.
|
void |
run() |
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSet
byteValue, shortValue
public boolean offer(T value)
SimpleQueue
offer
in interface SimpleQueue<T>
value
- 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() throws Exception
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>
Exception
- if some pre-processing of the dequeued
item (usually through fused functions) throws.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 void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
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 © 2019. All rights reserved.