Class MultipartSubscription

java.lang.Object
kong.unirest.core.java.MultipartSubscription
All Implemented Interfaces:
Flow.Subscription

class MultipartSubscription extends Object implements Flow.Subscription
  • Field Details

  • Constructor Details

  • Method Details

    • request

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

      public final void cancel()
      Specified by:
      cancel in interface Flow.Subscription
    • getAndAddDemand

      private long getAndAddDemand(Object owner, VarHandle demand, long n)
      Adds given count to demand not exceeding Long.MAX_VALUE.
    • subtractAndGetDemand

      private long subtractAndGetDemand(Object owner, VarHandle demand, long n)
      Subtracts given count from demand. Caller ensures result won't be negative.
    • signal

      public final void signal(boolean force)
      Schedules a signaller task. force tells whether to schedule in case of no demand
    • signalError

      public final void signalError(Throwable error)
    • isCancelled

      private final boolean isCancelled()
      Returns true if cancelled. false result is immediately outdated.
    • hasPendingErrors

      private final boolean hasPendingErrors()
      Returns true if the subscriber is to be completed exceptionally. false result is immediately outdated. Can be used by implementation to halt producing items in case the subscription was asynchronously signalled with an error.
    • cancelOnError

      private final void cancelOnError(Flow.Subscriber<? super ByteBuffer> downstream, Throwable error, boolean flowInterrupted)
      Calls downstream's onError after cancelling this subscription. flowInterrupted tells whether the error interrupted the normal flow of signals.
    • cancelOnComplete

      private final void cancelOnComplete(Flow.Subscriber<? super ByteBuffer> downstream)
      Calls downstream's onComplete after cancelling this subscription.
    • submitOnNext

      private final boolean submitOnNext(Flow.Subscriber<? super ByteBuffer> downstream, ByteBuffer item)
      Submits given item to the downstream, returning false and cancelling on failure.
    • signal

      private void signal()
    • run

      private void run()
    • subscribeOnDrain

      private void subscribeOnDrain(Flow.Subscriber<? super ByteBuffer> downstream)
    • propagateError

      private Throwable propagateError(Throwable error)
      Sets pending error or adds new one as suppressed in case of multiple error sources.
    • getAndBitwiseOrState

      private int getAndBitwiseOrState(int bits)
    • emit

      private long emit(Flow.Subscriber<? super ByteBuffer> downstream, long emit)
      Main method for item emission. At most e items are emitted to the downstream using {submitOnNext(Flow.Subscriber, Object)} as long as it returns true. The actual number of emitted items is returned, may be 0 in case of cancellation. If the underlying source is finished, the subscriber is completed with cancelOnComplete(Flow.Subscriber).
    • abort

      private void abort(boolean flowInterrupted)
      Called when the subscription is cancelled. flowInterrupted specifies whether cancellation was due to ending the normal flow of signals (signal|signalError) or due to flow interruption by downstream (e.g. calling cancel() or throwing from onNext).
    • pollNext

      private ByteBuffer pollNext()
    • nextPartHeaders

      private ByteBuffer nextPartHeaders()
    • subscribeToPart

      private boolean subscribeToPart(Part part)