Class Processors
- java.lang.Object
-
- io.servicetalk.concurrent.api.Processors
-
public final class Processors extends java.lang.ObjectStatic factory methods for creating processor instances for different type of sources. A processor is both a producer and a consumer of data.
-
-
Method Summary
-
-
-
Method Detail
-
newCompletableProcessor
public static CompletableSource.Processor newCompletableProcessor()
Create a newCompletableSource.Processorthat allows for multiplesubscribes. The returnedCompletableSource.Processorprovides all the expected API guarantees when used as aCompletableSourcebut does not expect the same guarantees when used as aCompletableSource.Subscriber. As an example, users are not expected to callCompletableSource.Subscriber.onSubscribe(Cancellable)or they can call any of theCompletableSource.Subscribermethods concurrently and/or multiple times.- Returns:
- a new
CompletableSource.Processorthat allows for multiplesubscribes.
-
newSingleProcessor
public static <T> SingleSource.Processor<T,T> newSingleProcessor()
Create a newSingleSource.Processorthat allows for multiplesubscribes. The returnedSingleSource.Processorprovides all the expected API guarantees when used as aSingleSourcebut does not expect the same guarantees when used as aSingleSource.Subscriber. As an example, users are not expected to callSingleSource.Subscriber.onSubscribe(Cancellable)or they can call any of theSingleSource.Subscribermethods concurrently and/or multiple times.- Type Parameters:
T- TheSingleSourcetype andSingleSource.Subscribertype of theSingleSource.Processor.- Returns:
- a new
SingleSource.Processorthat allows for multiplesubscribes.
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor()
Create a newPublisherSource.Processorthat allows for a singlesubscribe. The returnedPublisherSource.Processorprovides all the expected API guarantees when used as aPublisherSourcebut does not expect the same guarantees when used as aPublisherSource.Subscriber. As an example, users are not expected to callPublisherSource.Subscriber.onSubscribe(Subscription)or they can call any of thePublisherSource.Subscribermethods concurrently and/or multiple times.The returned may choose a default strategy to handle the cases when more items are added through
PublisherSource.Subscriber.onNext(Object)without being delivered to itsPublisherSource.Subscriber. Use other methods here if a specific strategy is required.- Type Parameters:
T- ThePublisherSourcetype andPublisherSource.Subscribertype of thePublisherSource.Processor.- Returns:
- a new
PublisherSource.Processorthat allows for a singlesubscribe. - See Also:
newPublisherProcessor(int),newPublisherProcessor(PublisherProcessorSignalsHolder)
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor(int maxBuffer)
Create a newPublisherSource.Processorthat allows for a singlesubscribe. The returnedPublisherSource.Processorprovides all the expected API guarantees when used as aPublisherSourcebut does not expect the same guarantees when used as aPublisherSource.Subscriber. As an example, users are not expected to callPublisherSource.Subscriber.onSubscribe(Subscription)or they can call any of thePublisherSource.Subscribermethods concurrently and/or multiple times.Only allows for
maxBuffernumber of items to be added throughPublisherSource.Subscriber.onNext(Object)without being delivered to itsPublisherSource.Subscriber. If more numbers are added without being delivered, subsequent additions will fail.- Type Parameters:
T- ThePublisherSourcetype andPublisherSource.Subscribertype of thePublisherSource.Processor.- Parameters:
maxBuffer- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processorthat allows for a singlesubscribe.
-
newPublisherProcessorDropHeadOnOverflow
public static <T> PublisherSource.Processor<T,T> newPublisherProcessorDropHeadOnOverflow(int maxBuffer)
Create a newPublisherSource.Processorthat allows for a singlesubscribe. The returnedPublisherSource.Processorprovides all the expected API guarantees when used as aPublisherSourcebut does not expect the same guarantees when used as aPublisherSource.Subscriber. As an example, users are not expected to callPublisherSource.Subscriber.onSubscribe(Subscription)or they can call any of thePublisherSource.Subscribermethods concurrently and/or multiple times.Only allows for
maxBuffernumber of items to be added throughPublisherSource.Subscriber.onNext(Object)without being delivered to itsPublisherSource.Subscriber. If more numbers are added without being delivered, the oldest buffered item (head) will be dropped.- Type Parameters:
T- ThePublisherSourcetype andPublisherSource.Subscribertype of thePublisherSource.Processor.- Parameters:
maxBuffer- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processorthat allows for a singlesubscribe.
-
newPublisherProcessorDropTailOnOverflow
public static <T> PublisherSource.Processor<T,T> newPublisherProcessorDropTailOnOverflow(int maxBuffer)
Create a newPublisherSource.Processorthat allows for a singlesubscribe. The returnedPublisherSource.Processorprovides all the expected API guarantees when used as aPublisherSourcebut does not expect the same guarantees when used as aPublisherSource.Subscriber. As an example, users are not expected to callPublisherSource.Subscriber.onSubscribe(Subscription)or they can call any of thePublisherSource.Subscribermethods concurrently and/or multiple times.Only allows for
maxBuffernumber of items to be added throughPublisherSource.Subscriber.onNext(Object)without being delivered to itsPublisherSource.Subscriber. If more numbers are added without being delivered, the latest buffered item (tail) will be dropped.- Type Parameters:
T- ThePublisherSourcetype andPublisherSource.Subscribertype of thePublisherSource.Processor.- Parameters:
maxBuffer- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processorthat allows for a singlesubscribe.
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor(PublisherProcessorSignalsHolder<T> holder)
Create a newPublisherSource.Processorthat allows for a singlesubscribe. The returnedPublisherSource.Processorprovides all the expected API guarantees when used as aPublisherSource. Users are expected to provide same API guarantees from the passedPublisherProcessorSignalsHolderas they use the returnedPublisherSource.Processoras aPublisherSource.Subscriber. As an example, if users callPublisherSource.Subscribermethods concurrently the passedPublisherProcessorSignalsHoldershould support concurrent invocation of its methods.- Type Parameters:
T- ThePublisherSourcetype andPublisherSource.Subscribertype of thePublisherSource.Processor.- Parameters:
holder- APublisherProcessorSignalsHolderto store items that are requested to be sent viaPublisherSource.Subscriber.onNext(Object)but not yet emitted to thePublisherSource.Subscriber.- Returns:
- a new
PublisherSource.Processorthat allows for a singlesubscribe.
-
newBlockingIterableProcessor
public static <T> BlockingIterable.Processor<T> newBlockingIterableProcessor()
Create a newBlockingIterable.Processor.- Type Parameters:
T- the type of elements emitted by the returnedBlockingIterable.- Returns:
- a new
BlockingIterable.Processor.
-
newBlockingIterableProcessor
public static <T> BlockingIterable.Processor<T> newBlockingIterableProcessor(int maxBufferSize)
Create a newBlockingIterable.Processor.- Type Parameters:
T- the type of elements emitted by the returnedBlockingIterable.- Parameters:
maxBufferSize- Maximum number of items that are requested to be sent viaBlockingIterable.Processor.next(Object)but not yet emitted from aBlockingIterator. If this buffer size is reached a subsequent call toemitwill block till an item is emitted from aBlockingIterator.- Returns:
- a new
BlockingIterable.Processor.
-
newBlockingIterableProcessor
public static <T> BlockingIterable.Processor<T> newBlockingIterableProcessor(BlockingProcessorSignalsHolder<T> holder)
Create a newBlockingIterable.Processor.- Type Parameters:
T- the type of elements emitted by the returnedBlockingIterable.- Parameters:
holder- ABlockingProcessorSignalsHolderto store items that are requested to be sent viaBlockingIterable.Processor.next(Object)but not yet emitted from aBlockingIterator.- Returns:
- a new
BlockingIterable.Processor.
-
-