Object
SynchronousPublisher<T>
- All Implemented Interfaces:
AutoCloseable
,Flow.Publisher<T>
- Direct Known Subclasses:
TransformProcessor
Publisher which has no internal queues and which delivers items to subscribers synchronously.
Items are delivered through Flow.Subscriber.onNext(Object)
:
- using same thread where
submit(Object)
method is called - in same order in which subscribers were subscribed to this publisher
This publisher will never loose any item as it will block indefinitely until at least one subscriber requests and receives it.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
closeExceptionally
(Throwable error) Unless already closed, issueonError
to existing subscribers and disallows subsequentsubmit(Object)
attempts.void
Publishes the given item to each current subscriber by synchronously invoking itsonNext
method.void
subscribe
(Flow.Subscriber<? super T> subscriber)
-
Constructor Details
-
SynchronousPublisher
public SynchronousPublisher()
-
-
Method Details
-
subscribe
- Specified by:
subscribe
in interfaceFlow.Publisher<T>
-
submit
Publishes the given item to each current subscriber by synchronously invoking itsonNext
method.If there is no active subscribers, or none of the subscribers requested new items then this method blocks. It will unblock only when one of the following things happens:
close()
is called ORcloseExceptionally(Throwable)
is called OR- one of the
Flow.Subscriber
requested an item
-
closeExceptionally
Unless already closed, issueonError
to existing subscribers and disallows subsequentsubmit(Object)
attempts. Future subscribers also receive the given error. -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-