Class OutputStreamPublisher

    • Constructor Detail

      • OutputStreamPublisher

        public OutputStreamPublisher()
    • Method Detail

      • subscribe

        public void subscribe​(Flow.Subscriber<? super ByteBuffer> subscriberParam)
        Description copied from interface: Flow.Publisher
        Adds the given Subscriber if possible. If already subscribed, or the attempt to subscribe fails due to policy violations or errors, the Subscriber's onError method is invoked with an IllegalStateException. Otherwise, the Subscriber's onSubscribe method is invoked with a new Flow.Subscription. Subscribers may enable receiving items by invoking the request method of this Subscription, and may unsubscribe by invoking its cancel method.
        Specified by:
        subscribe in interface Flow.Publisher<ByteBuffer>
        Parameters:
        subscriberParam - the subscriber
      • signalCloseComplete

        public void signalCloseComplete​(Throwable throwable)
        Signals this publishing output stream that it can safely return from otherwise blocking invocation to it's close() method. Subsequent multiple invocations of this method are allowed, but have no effect on this publishing output stream.

        When the close() method on this output stream is invoked, it will block waiting for a signal to complete. This is useful in cases, when the receiving side needs to synchronize it's completion with the publisher, e.g. to ensure that any resources used by the subscribing party are not released prematurely due to a premature exit from publishing output stream close() method.

        Additionally, this mechanism can be used to propagate any downstream completion exceptions back to this publisher and up it's call stack. When a non-null throwable parameter is passed into the method, it will be wrapped in an IOException and thrown from the close() method when it is invoked.

        Parameters:
        throwable - represents a completion error condition that should be thrown when a close() method is invoked on this publishing output stream. If set to null, the close() method will exit normally.