Interface SignalOffloader
-
- All Known Implementing Classes:
DelegatingSignalOffloader
public interface SignalOffloader
A contract to offload signals to and from any asynchronous source.Caution
ASignalOffloader
instance MUST only be used for a single asynchronous execution chain at any given time. Reusing it across different execution chains concurrently may result in deadlock. Concurrent invocation of anySignalOffloader
methods may result in deadlock.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableSource.Subscriber
offloadCancellable(CompletableSource.Subscriber subscriber)
Decorates the passedCompletableSource.Subscriber
such that all method calls to itsCancellable
will be offloaded.<T> SingleSource.Subscriber<? super T>
offloadCancellable(SingleSource.Subscriber<? super T> subscriber)
Decorates the passedSingleSource.Subscriber
such that all method calls to itsCancellable
will be offloaded.<T> void
offloadSignal(T signal, java.util.function.Consumer<T> signalConsumer)
Offloads the consumption of the passedsignal
by the passedConsumer
.void
offloadSubscribe(CompletableSource.Subscriber subscriber, java.util.function.Consumer<CompletableSource.Subscriber> handleSubscribe)
Offloads the subscribe call for the passedPublisherSource.Subscriber
.<T> void
offloadSubscribe(PublisherSource.Subscriber<? super T> subscriber, java.util.function.Consumer<PublisherSource.Subscriber<? super T>> handleSubscribe)
Offloads subscribe call for the passedPublisherSource.Subscriber
.<T> void
offloadSubscribe(SingleSource.Subscriber<? super T> subscriber, java.util.function.Consumer<SingleSource.Subscriber<? super T>> handleSubscribe)
Offloads subscribe call for the passedPublisherSource.Subscriber
.CompletableSource.Subscriber
offloadSubscriber(CompletableSource.Subscriber subscriber)
Decorates the passedCompletableSource.Subscriber
such that all method calls to it will be offloaded.<T> PublisherSource.Subscriber<? super T>
offloadSubscriber(PublisherSource.Subscriber<? super T> subscriber)
Decorates the passedPublisherSource.Subscriber
such that all method calls to it will be offloaded.<T> SingleSource.Subscriber<? super T>
offloadSubscriber(SingleSource.Subscriber<? super T> subscriber)
Decorates the passedSingleSource.Subscriber
such that all method calls to it will be offloaded.<T> PublisherSource.Subscriber<? super T>
offloadSubscription(PublisherSource.Subscriber<? super T> subscriber)
Decorates the passedPublisherSource.Subscriber
such that all method calls to itsPublisherSource.Subscription
will be offloaded.
-
-
-
Method Detail
-
offloadSubscriber
<T> PublisherSource.Subscriber<? super T> offloadSubscriber(PublisherSource.Subscriber<? super T> subscriber)
Decorates the passedPublisherSource.Subscriber
such that all method calls to it will be offloaded.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of items received by the passed and returnedPublisherSource.Subscriber
.- Parameters:
subscriber
-PublisherSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
PublisherSource.Subscriber
that will offload signals to the passedPublisherSource.Subscriber
.
-
offloadSubscriber
<T> SingleSource.Subscriber<? super T> offloadSubscriber(SingleSource.Subscriber<? super T> subscriber)
Decorates the passedSingleSource.Subscriber
such that all method calls to it will be offloaded.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of items received by the passed and returnedSingleSource.Subscriber
.- Parameters:
subscriber
-SingleSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
SingleSource.Subscriber
that will offload signals to the passedSingleSource.Subscriber
.
-
offloadSubscriber
CompletableSource.Subscriber offloadSubscriber(CompletableSource.Subscriber subscriber)
Decorates the passedCompletableSource.Subscriber
such that all method calls to it will be offloaded.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Parameters:
subscriber
-CompletableSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
CompletableSource.Subscriber
that will offload signals to the passedCompletableSource.Subscriber
.
-
offloadSubscription
<T> PublisherSource.Subscriber<? super T> offloadSubscription(PublisherSource.Subscriber<? super T> subscriber)
Decorates the passedPublisherSource.Subscriber
such that all method calls to itsPublisherSource.Subscription
will be offloaded. None of thePublisherSource.Subscriber
methods will be offloaded.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of items received by the passed and returnedPublisherSource.Subscriber
.- Parameters:
subscriber
-PublisherSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
PublisherSource.Subscriber
that will offload signals to the passedPublisherSource.Subscriber
.
-
offloadCancellable
<T> SingleSource.Subscriber<? super T> offloadCancellable(SingleSource.Subscriber<? super T> subscriber)
Decorates the passedSingleSource.Subscriber
such that all method calls to itsCancellable
will be offloaded. None of theSingleSource.Subscriber
methods will be offloaded.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of items received by the passed and returnedSingleSource.Subscriber
.- Parameters:
subscriber
-SingleSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
SingleSource.Subscriber
that will offload signals to the passedSingleSource.Subscriber
.
-
offloadCancellable
CompletableSource.Subscriber offloadCancellable(CompletableSource.Subscriber subscriber)
Decorates the passedCompletableSource.Subscriber
such that all method calls to itsCancellable
will be offloaded. None of theCompletableSource.Subscriber
methods will be offloaded.Caution
LoadBalancerReadyHttpClientTest This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Parameters:
subscriber
-CompletableSource.Subscriber
for which the signals are to be offloaded.- Returns:
- New
CompletableSource.Subscriber
that will offload signals to the passedCompletableSource.Subscriber
.
-
offloadSubscribe
<T> void offloadSubscribe(PublisherSource.Subscriber<? super T> subscriber, java.util.function.Consumer<PublisherSource.Subscriber<? super T>> handleSubscribe)
Offloads subscribe call for the passedPublisherSource.Subscriber
.Offloading Failures
Implementations are expected to handle failure to offload, e.g. If a thread pool is used to offload and it rejects task submissions. In such situations, it is expected that the passedPublisherSource.Subscriber
will be correctly terminated.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of signal.- Parameters:
subscriber
-PublisherSource.Subscriber
for which subscribe call has to be offloaded.handleSubscribe
-Consumer
to handle the offloaded subscribe call.
-
offloadSubscribe
<T> void offloadSubscribe(SingleSource.Subscriber<? super T> subscriber, java.util.function.Consumer<SingleSource.Subscriber<? super T>> handleSubscribe)
Offloads subscribe call for the passedPublisherSource.Subscriber
.Offloading Failures
Implementations are expected to handle failure to offload, e.g. If a thread pool is used to offload and it rejects task submissions. In such situations, it is expected that the passedPublisherSource.Subscriber
will be correctly terminated.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of signal.- Parameters:
subscriber
-SingleSource.Subscriber
for which subscribe call has to be offloaded.handleSubscribe
-Consumer
to handle the offloaded subscribe call.
-
offloadSubscribe
void offloadSubscribe(CompletableSource.Subscriber subscriber, java.util.function.Consumer<CompletableSource.Subscriber> handleSubscribe)
Offloads the subscribe call for the passedPublisherSource.Subscriber
.Offloading Failures
Implementations are expected to handle failure to offload, e.g. If a thread pool is used to offload and it rejects task submissions. In such situations, it is expected that the passedPublisherSource.Subscriber
will be correctly terminated.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Parameters:
subscriber
-PublisherSource.Subscriber
for which for which subscribe call has to be offloaded.handleSubscribe
-Consumer
to handle the offloaded subscribe call.
-
offloadSignal
<T> void offloadSignal(T signal, java.util.function.Consumer<T> signalConsumer)
Offloads the consumption of the passedsignal
by the passedConsumer
.Caution
This method MUST not be called concurrently with itself or other offload methods here on the sameSignalOffloader
instance.- Type Parameters:
T
- Type of signal.- Parameters:
signal
-signal
to send to theConsumer
.signalConsumer
-Consumer
of the signal.
-
-