public final class UnicastContentSubject<T>
extends rx.subjects.Subject<T,T>
Subject
implementation to be used by HttpClientResponse
and HttpServerRequest
.
Observable
as any code can hold the reference to
this Observable
at any point in time and hence subscribe to it at any time. This will eventually increase
memory consumption as we will hold on to the content buffers for more time than required.
Subject
one should use a
Observable.publish()
operator.
ByteBuf
which needs to be released explicitly.
In order to avoid this leak, this subject provides a "no subscription timeout" which disposes this subject (calling
disposeIfNotSubscribed()
if it does not get a subscription in the configured timeout duration.
The buffer is only utilized if there are any items emitted to this subject before a subscription arrives. After a
subscription arrives, this subject becomes a pass through i.e. it does not buffer before sending the notifications.
This implementation is inspired by
RxJava's BufferUntilSubscriberModifier and Type | Method and Description |
---|---|
static <T> UnicastContentSubject<T> |
create(long noSubscriptionTimeout,
java.util.concurrent.TimeUnit timeUnit) |
static <T> UnicastContentSubject<T> |
create(long noSubscriptionTimeout,
java.util.concurrent.TimeUnit timeUnit,
rx.functions.Action0 onUnsubscribe) |
static <T> UnicastContentSubject<T> |
create(long noSubscriptionTimeout,
java.util.concurrent.TimeUnit timeUnit,
rx.Scheduler timeoutScheduler) |
static <T> UnicastContentSubject<T> |
create(long noSubscriptionTimeout,
java.util.concurrent.TimeUnit timeUnit,
rx.Scheduler timeoutScheduler,
rx.functions.Action0 onUnsubscribe) |
static <T> UnicastContentSubject<T> |
createWithoutNoSubscriptionTimeout()
Creates a new
UnicastContentSubject without a no subscription timeout. |
static <T> UnicastContentSubject<T> |
createWithoutNoSubscriptionTimeout(rx.functions.Action0 onUnsubscribe)
Creates a new
UnicastContentSubject without a no subscription timeout. |
boolean |
disposeIfNotSubscribed()
This will eagerly dispose this
Subject without waiting for the no subscription timeout period,
if configured. |
boolean |
hasObservers() |
void |
onCompleted() |
void |
onError(java.lang.Throwable e) |
void |
onNext(T t) |
void |
updateTimeoutIfNotScheduled(long noSubscriptionTimeout,
java.util.concurrent.TimeUnit timeUnit) |
all, amb, amb, amb, amb, amb, amb, amb, amb, amb, ambWith, asObservable, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, cache, cache, cast, collect, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, compose, concat, concat, concat, concat, concat, concat, concat, concat, concat, concatMap, concatWith, contains, count, countLong, create, debounce, debounce, debounce, defaultIfEmpty, defer, delay, delay, delay, delay, delaySubscription, delaySubscription, delaySubscription, dematerialize, distinct, distinct, distinctUntilChanged, distinctUntilChanged, doOnCompleted, doOnEach, doOnEach, doOnError, doOnNext, doOnSubscribe, doOnTerminate, doOnUnsubscribe, elementAt, elementAtOrDefault, empty, error, exists, filter, finallyDo, first, first, firstOrDefault, firstOrDefault, flatMap, flatMap, flatMap, flatMapIterable, flatMapIterable, forEach, forEach, forEach, from, from, from, from, from, groupBy, groupBy, groupJoin, ignoreElements, interval, interval, isEmpty, join, just, just, just, just, just, just, just, just, just, just, last, last, lastOrDefault, lastOrDefault, lift, limit, map, materialize, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeWith, nest, never, observeOn, ofType, onBackpressureBuffer, onBackpressureDrop, onErrorResumeNext, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, publish, publish, range, range, reduce, reduce, reduce, repeat, repeat, repeat, repeat, repeatWhen, repeatWhen, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, retry, retry, retry, retryWhen, retryWhen, sample, sample, sample, scan, scan, scan, sequenceEqual, sequenceEqual, serialize, share, single, single, singleOrDefault, singleOrDefault, skip, skip, skip, skipLast, skipLast, skipLast, skipUntil, skipWhile, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, switchMap, switchOnNext, take, take, take, takeFirst, takeLast, takeLast, takeLast, takeLast, takeLast, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeUntil, takeWhile, throttleFirst, throttleFirst, throttleLast, throttleLast, throttleWithTimeout, throttleWithTimeout, timeInterval, timeInterval, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timer, timer, timer, timer, timestamp, timestamp, toBlocking, toList, toMap, toMap, toMap, toMultimap, toMultimap, toMultimap, toMultimap, toSortedList, toSortedList, unsafeSubscribe, unsubscribeOn, using, window, window, window, window, window, window, window, window, window, window, window, window, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWith
public static <T> UnicastContentSubject<T> createWithoutNoSubscriptionTimeout(rx.functions.Action0 onUnsubscribe)
UnicastContentSubject
without a no subscription timeout.
This can cause a memory leak in case no one ever subscribes to this subject. See
UnicastContentSubject
for details.T
- The type emitted and received by this subject.onUnsubscribe
- An action to be invoked when the sole subscriber to this Subject
unsubscribes.UnicastContentSubject
public static <T> UnicastContentSubject<T> createWithoutNoSubscriptionTimeout()
UnicastContentSubject
without a no subscription timeout.
This can cause a memory leak in case no one ever subscribes to this subject. See
UnicastContentSubject
for details.T
- The type emitted and received by this subject.UnicastContentSubject
public static <T> UnicastContentSubject<T> create(long noSubscriptionTimeout, java.util.concurrent.TimeUnit timeUnit)
public static <T> UnicastContentSubject<T> create(long noSubscriptionTimeout, java.util.concurrent.TimeUnit timeUnit, rx.functions.Action0 onUnsubscribe)
public static <T> UnicastContentSubject<T> create(long noSubscriptionTimeout, java.util.concurrent.TimeUnit timeUnit, rx.Scheduler timeoutScheduler)
public static <T> UnicastContentSubject<T> create(long noSubscriptionTimeout, java.util.concurrent.TimeUnit timeUnit, rx.Scheduler timeoutScheduler, rx.functions.Action0 onUnsubscribe)
public boolean disposeIfNotSubscribed()
Subject
without waiting for the no subscription timeout period,
if configured.
This must be invoked when the caller is sure that no one will subscribe to this subject. Any subscriber after
this call will receive an error that the subject is disposed.true
if the subject was disposed by this call (if and only if there was no subscription).public void updateTimeoutIfNotScheduled(long noSubscriptionTimeout, java.util.concurrent.TimeUnit timeUnit)
public void onCompleted()
public void onError(java.lang.Throwable e)
public void onNext(T t)