Interface SimpleQueue<T>

Type Parameters:
T - the value type to offer and poll, not null
All Known Subinterfaces:
MaybeMergeArray.SimpleQueueWithConsumerIndex<T>, QueueDisposable<T>, QueueFuseable<T>, QueueSubscription<T>, SimplePlainQueue<T>
All Known Implementing Classes:
AbstractEmptyQueueFuseable, AsyncProcessor.AsyncSubscription, AsyncSubject.AsyncDisposable, BasicFuseableConditionalSubscriber, BasicFuseableObserver, BasicFuseableSubscriber, BasicIntQueueDisposable, BasicIntQueueSubscription, BasicQueueDisposable, BasicQueueSubscription, CancellableQueueFuseable, DeferredScalarDisposable, DeferredScalarObserver, DeferredScalarSubscriber, DeferredScalarSubscription, EmptyDisposable, EmptySubscription, FlowableAll.AllSubscriber, FlowableAny.AnySubscriber, FlowableCollect.CollectSubscriber, FlowableCollectWithCollector.CollectorSubscriber, FlowableCombineLatest.CombineLatestCoordinator, FlowableCount.CountSubscriber, FlowableDistinct.DistinctSubscriber, FlowableDistinctUntilChanged.DistinctUntilChangedConditionalSubscriber, FlowableDistinctUntilChanged.DistinctUntilChangedSubscriber, FlowableDoAfterNext.DoAfterConditionalSubscriber, FlowableDoAfterNext.DoAfterSubscriber, FlowableDoFinally.DoFinallyConditionalSubscriber, FlowableDoFinally.DoFinallySubscriber, FlowableDoOnEach.DoOnEachConditionalSubscriber, FlowableDoOnEach.DoOnEachSubscriber, FlowableElementAt.ElementAtSubscriber, FlowableFilter.FilterConditionalSubscriber, FlowableFilter.FilterSubscriber, FlowableFlatMapCompletable.FlatMapCompletableMainSubscriber, FlowableFlattenIterable.FlattenIterableSubscriber, FlowableFromArray.ArrayConditionalSubscription, FlowableFromArray.ArraySubscription, FlowableFromArray.BaseArraySubscription, FlowableFromCompletable.FromCompletableObserver, FlowableFromCompletionStage.CompletionStageHandler, FlowableFromIterable.BaseRangeSubscription, FlowableFromIterable.IteratorConditionalSubscription, FlowableFromIterable.IteratorSubscription, FlowableFromStream.AbstractStreamSubscription, FlowableFromStream.StreamConditionalSubscription, FlowableFromStream.StreamSubscription, FlowableGroupBy.State, FlowableIgnoreElements.IgnoreElementsSubscriber, FlowableMap.MapConditionalSubscriber, FlowableMap.MapSubscriber, FlowableMapOptional.MapOptionalConditionalSubscriber, FlowableMapOptional.MapOptionalSubscriber, FlowableObserveOn.BaseObserveOnSubscriber, FlowableObserveOn.ObserveOnConditionalSubscriber, FlowableObserveOn.ObserveOnSubscriber, FlowableOnBackpressureBuffer.BackpressureBufferSubscriber, FlowableRange.BaseRangeSubscription, FlowableRange.RangeConditionalSubscription, FlowableRange.RangeSubscription, FlowableRangeLong.BaseRangeSubscription, FlowableRangeLong.RangeConditionalSubscription, FlowableRangeLong.RangeSubscription, FlowableReduce.ReduceSubscriber, FlowableSequenceEqual.EqualCoordinator, FlowableSingle.SingleElementSubscriber, FlowableTakeLastOne.TakeLastOneSubscriber, FlowableToList.ToListSubscriber, MaybeFlatMapIterableFlowable.FlatMapIterableObserver, MaybeFlatMapIterableObservable.FlatMapIterableObserver, MaybeFlattenStreamAsFlowable.FlattenStreamMultiObserver, MaybeFlattenStreamAsObservable.FlattenStreamMultiObserver, MaybeMergeArray.ClqSimpleQueue, MaybeMergeArray.MergeMaybeObserver, MaybeMergeArray.MpscFillOnceSimpleQueue, MaybeToFlowable.MaybeToFlowableSubscriber, MaybeToObservable.MaybeToObservableObserver, MpscLinkedQueue, ObservableCollectWithCollector.CollectorObserver, ObservableDistinct.DistinctObserver, ObservableDistinctUntilChanged.DistinctUntilChangedObserver, ObservableDoAfterNext.DoAfterObserver, ObservableDoFinally.DoFinallyObserver, ObservableFilter.FilterObserver, ObservableFlatMapCompletable.FlatMapCompletableMainObserver, ObservableFromArray.FromArrayDisposable, ObservableFromCompletable.FromCompletableObserver, ObservableFromCompletionStage.CompletionStageHandler, ObservableFromIterable.FromIterableDisposable, ObservableFromStream.StreamDisposable, ObservableMap.MapObserver, ObservableMapOptional.MapOptionalObserver, ObservableObserveOn.ObserveOnObserver, ObservableRange.RangeDisposable, ObservableRangeLong.RangeDisposable, ObservableScalarXMap.ScalarDisposable, ParallelCollect.ParallelCollectSubscriber, ParallelCollector.ParallelCollectorSubscriber, ParallelReduce.ParallelReduceSubscriber, ParallelReduceFull.ParallelReduceFullMainSubscriber, ScalarSubscription, SingleFlatMapIterableFlowable.FlatMapIterableObserver, SingleFlatMapIterableObservable.FlatMapIterableObserver, SingleToFlowable.SingleToFlowableObserver, SingleToObservable.SingleToObservableObserver, SpscArrayQueue, SpscLinkedArrayQueue, UnicastProcessor.UnicastQueueSubscription, UnicastSubject.UnicastQueueDisposable

public interface SimpleQueue<@NonNull T>
A simplified interface for offering, polling and clearing a queue.

This interface does not define most of the Collection or Queue methods as the intended usage of SimpleQueue does not require support for iteration or introspection.

Since:
3.1.1
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all enqueued items from this queue.
    boolean
    Returns true if the queue is empty.
    boolean
    offer(@NonNull T value)
    Atomically enqueue a single value.
    boolean
    Atomically enqueue two values.
    Tries to dequeue a value (non-null) or returns null if the queue is empty.
  • Method Details

    • offer

      boolean offer(@NonNull @NonNull T value)
      Atomically enqueue a single value.
      Parameters:
      value - the value to enqueue, not null
      Returns:
      true if successful, false if the value was not enqueued likely due to reaching the queue capacity)
    • offer

      boolean offer(@NonNull @NonNull T v1, @NonNull @NonNull T v2)
      Atomically enqueue two values.
      Parameters:
      v1 - the first value to enqueue, not null
      v2 - the second value to enqueue, not null
      Returns:
      true if successful, false if the value was not enqueued likely due to reaching the queue capacity)
    • poll

      @Nullable T poll() throws Throwable
      Tries to dequeue a value (non-null) or returns null if the queue is empty.

      If the producer uses 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.

      Returns:
      the item or null to indicate an empty queue
      Throws:
      Throwable - if some pre-processing of the dequeued item (usually through fused functions) throws.
    • isEmpty

      boolean isEmpty()
      Returns true if the queue is empty.

      Note however that due to potential fused functions in poll() it is possible this method returns false but then poll() returns null because the fused function swallowed the available item(s).

      Returns:
      true if the queue is empty
    • clear

      void clear()
      Removes all enqueued items from this queue.