Class AsyncIterablePublisher<T>
java.lang.Object
org.reactivestreams.example.unicast.AsyncIterablePublisher<T>
- All Implemented Interfaces:
Publisher<T>
- Direct Known Subclasses:
HelperPublisher
,InfiniteHelperPublisher
,InfiniteIncrementNumberPublisher
,NumberIterablePublisher
AsyncIterablePublisher is an implementation of Reactive Streams `Publisher`
which executes asynchronously, using a provided `Executor` and produces elements
from a given `Iterable` in a "unicast" configuration to its `Subscribers`.
NOTE: The code below uses a lot of try-catches to show the reader where exceptions can be expected, and where they are forbidden.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
(package private) static final class
(package private) static enum
(package private) static interface
(package private) static enum
(package private) final class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAsyncIterablePublisher
(Iterable<T> elements, int batchSize, Executor executor) AsyncIterablePublisher
(Iterable<T> elements, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
subscribe
(Subscriber<? super T> s) RequestPublisher
to start streaming data.
-
Field Details
-
DEFAULT_BATCHSIZE
private static final int DEFAULT_BATCHSIZE- See Also:
-
elements
-
executor
-
batchSize
private final int batchSize
-
-
Constructor Details
-
AsyncIterablePublisher
-
AsyncIterablePublisher
-
-
Method Details
-
subscribe
Description copied from interface:Publisher
RequestPublisher
to start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
.Each
Subscription
will work for only a singleSubscriber
.A
Subscriber
should only subscribe once to a singlePublisher
.If the
Publisher
rejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(Throwable)
.- Specified by:
subscribe
in interfacePublisher<T>
- Parameters:
s
- theSubscriber
that will consume signals from thisPublisher
-