Module iu.util
Package edu.iu

Interface IuAsynchronousSubscription<T>

Type Parameters:
T - value type
All Superinterfaces:
AutoCloseable

public interface IuAsynchronousSubscription<T> extends AutoCloseable
Provides access to subscription resources for an IuAsynchronousSubject.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets an estimated number of values that may be advanced by the stream without blocking.
    void
     
    void
    Reports an error that occurred that should terminate the subscription.
    boolean
    Determines whether or not the subscription is closed.
    long
    pause(long acceptedCount, Duration timeout)
    Pauses execution on the current thread until new values are accepted.
    long
    pause(Instant expires)
    Pauses execution until either a timeout interval expires or the subject is closed.
    Gets a stream over all values, including those accepted after the subscription was created.
  • Method Details

    • stream

      Stream<T> stream()
      Gets a stream over all values, including those accepted after the subscription was created.
      Returns:
      Stream
    • isClosed

      boolean isClosed()
      Determines whether or not the subscription is closed.

      Once closed, all remaining values can be advanced without blocking.

      Returns:
      true if close; else false
    • available

      long available()
      Gets an estimated number of values that may be advanced by the stream without blocking.
      Returns:
      available values
    • pause

      long pause(long acceptedCount, Duration timeout) throws TimeoutException, InterruptedException
      Pauses execution on the current thread until new values are accepted.

      This method has no effect on a subscription not yet backed by IuAsynchronousPipe.

      Parameters:
      acceptedCount - count of newly accepted values to wait for; returns without delay if <= 0
      timeout - amount of time to wait; should be positive
      Returns:
      the actual number of values accepted while paused
      Throws:
      TimeoutException - if the timeout interval expires before receivedCount values are received
      InterruptedException - if the current thread is interrupted while waiting for values to be received
      See Also:
    • pause

      long pause(Instant expires) throws InterruptedException
      Pauses execution until either a timeout interval expires or the subject is closed.

      This method has no effect on a subscription not yet backed by IuAsynchronousPipe.

      Parameters:
      expires - instant the timeout interval expires
      Returns:
      the number of values accepted onto the pipe while paused
      Throws:
      InterruptedException - if the current thread is interrupted while waiting for the pipe to close
      See Also:
    • error

      void error(Throwable e)
      Reports an error that occurred that should terminate the subscription.
      Parameters:
      e - Throwable
    • close

      void close()
      Specified by:
      close in interface AutoCloseable