Class StrictSubscriber<T>

java.lang.Object
java.lang.Number
java.util.concurrent.atomic.AtomicInteger
io.reactivex.rxjava3.internal.subscribers.StrictSubscriber<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
FlowableSubscriber<T>, Serializable, org.reactivestreams.Subscriber<T>, org.reactivestreams.Subscription

public class StrictSubscriber<T> extends AtomicInteger implements FlowableSubscriber<T>, org.reactivestreams.Subscription
Ensures that the event flow between the upstream and downstream follow the Reactive-Streams 1.0 specification by honoring the 3 additional rules (which are omitted in standard operators due to performance reasons).
  • §1.3: onNext should not be called concurrently until onSubscribe returns
  • §2.3: onError or onComplete must not call cancel
  • §3.9: negative requests should emit an onError(IllegalArgumentException)
In addition, if rule §2.12 (onSubscribe must be called at most once) is violated, the sequence is cancelled an onError(IllegalStateException) is emitted.
Since:
2.0.7
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • downstream

      final org.reactivestreams.Subscriber<? super T> downstream
    • error

      final AtomicThrowable error
    • requested

      final AtomicLong requested
    • upstream

      final AtomicReference<org.reactivestreams.Subscription> upstream
    • once

      final AtomicBoolean once
    • done

      volatile boolean done
  • Constructor Details

    • StrictSubscriber

      public StrictSubscriber(org.reactivestreams.Subscriber<? super T> downstream)
  • Method Details

    • request

      public void request(long n)
      Specified by:
      request in interface org.reactivestreams.Subscription
    • cancel

      public void cancel()
      Specified by:
      cancel in interface org.reactivestreams.Subscription
    • onSubscribe

      public void onSubscribe(org.reactivestreams.Subscription s)
      Description copied from interface: FlowableSubscriber
      Implementors of this method should make sure everything that needs to be visible in Subscriber.onNext(Object) is established before calling Subscription.request(long). In practice this means no initialization should happen after the request() call and additional behavior is thread safe in respect to onNext.
      Specified by:
      onSubscribe in interface FlowableSubscriber<T>
      Specified by:
      onSubscribe in interface org.reactivestreams.Subscriber<T>
    • onNext

      public void onNext(T t)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<T>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface org.reactivestreams.Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface org.reactivestreams.Subscriber<T>