Class Processors
- java.lang.Object
-
- io.servicetalk.concurrent.api.Processors
-
public final class Processors extends java.lang.Object
Static 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.Processor
that allows for multiplesubscribes
. The returnedCompletableSource.Processor
provides all the expected API guarantees when used as aCompletableSource
but 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.Subscriber
methods concurrently and/or multiple times.- Returns:
- a new
CompletableSource.Processor
that allows for multiplesubscribes
.
-
newSingleProcessor
public static <T> SingleSource.Processor<T,T> newSingleProcessor()
Create a newSingleSource.Processor
that allows for multiplesubscribes
. The returnedSingleSource.Processor
provides all the expected API guarantees when used as aSingleSource
but 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.Subscriber
methods concurrently and/or multiple times.- Type Parameters:
T
- TheSingleSource
type andSingleSource.Subscriber
type of theSingleSource.Processor
.- Returns:
- a new
SingleSource.Processor
that allows for multiplesubscribes
.
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor()
Create a newPublisherSource.Processor
that allows for a singlesubscribe
. The returnedPublisherSource.Processor
provides all the expected API guarantees when used as aPublisherSource
but 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.Subscriber
methods 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
- ThePublisherSource
type andPublisherSource.Subscriber
type of thePublisherSource.Processor
.- Returns:
- a new
PublisherSource.Processor
that allows for a singlesubscribe
. - See Also:
newPublisherProcessor(int)
,newPublisherProcessor(PublisherProcessorSignalsHolder)
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor(int maxBuffer)
Create a newPublisherSource.Processor
that allows for a singlesubscribe
. The returnedPublisherSource.Processor
provides all the expected API guarantees when used as aPublisherSource
but 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.Subscriber
methods concurrently and/or multiple times.Only allows for
maxBuffer
number 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
- ThePublisherSource
type andPublisherSource.Subscriber
type of thePublisherSource.Processor
.- Parameters:
maxBuffer
- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processor
that allows for a singlesubscribe
.
-
newPublisherProcessorDropHeadOnOverflow
public static <T> PublisherSource.Processor<T,T> newPublisherProcessorDropHeadOnOverflow(int maxBuffer)
Create a newPublisherSource.Processor
that allows for a singlesubscribe
. The returnedPublisherSource.Processor
provides all the expected API guarantees when used as aPublisherSource
but 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.Subscriber
methods concurrently and/or multiple times.Only allows for
maxBuffer
number 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
- ThePublisherSource
type andPublisherSource.Subscriber
type of thePublisherSource.Processor
.- Parameters:
maxBuffer
- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processor
that allows for a singlesubscribe
.
-
newPublisherProcessorDropTailOnOverflow
public static <T> PublisherSource.Processor<T,T> newPublisherProcessorDropTailOnOverflow(int maxBuffer)
Create a newPublisherSource.Processor
that allows for a singlesubscribe
. The returnedPublisherSource.Processor
provides all the expected API guarantees when used as aPublisherSource
but 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.Subscriber
methods concurrently and/or multiple times.Only allows for
maxBuffer
number 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
- ThePublisherSource
type andPublisherSource.Subscriber
type of thePublisherSource.Processor
.- Parameters:
maxBuffer
- Maximum number of items to buffer.- Returns:
- a new
PublisherSource.Processor
that allows for a singlesubscribe
.
-
newPublisherProcessor
public static <T> PublisherSource.Processor<T,T> newPublisherProcessor(PublisherProcessorSignalsHolder<T> holder)
Create a newPublisherSource.Processor
that allows for a singlesubscribe
. The returnedPublisherSource.Processor
provides all the expected API guarantees when used as aPublisherSource
. Users are expected to provide same API guarantees from the passedPublisherProcessorSignalsHolder
as they use the returnedPublisherSource.Processor
as aPublisherSource.Subscriber
. As an example, if users callPublisherSource.Subscriber
methods concurrently the passedPublisherProcessorSignalsHolder
should support concurrent invocation of its methods.- Type Parameters:
T
- ThePublisherSource
type andPublisherSource.Subscriber
type of thePublisherSource.Processor
.- Parameters:
holder
- APublisherProcessorSignalsHolder
to store items that are requested to be sent viaPublisherSource.Subscriber.onNext(Object)
but not yet emitted to thePublisherSource.Subscriber
.- Returns:
- a new
PublisherSource.Processor
that 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 toemit
will 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
- ABlockingProcessorSignalsHolder
to store items that are requested to be sent viaBlockingIterable.Processor.next(Object)
but not yet emitted from aBlockingIterator
.- Returns:
- a new
BlockingIterable.Processor
.
-
-