Top Description Inners Fields Constructors Methods
io.reactivex.internal.operators.observable

public final Class ObservablePublish<T>

extends ConnectableObservable<T>
implements HasUpstreamObservableSource<T>, ObservablePublishClassic<T>
Class Inheritance
All Implemented Interfaces
io.reactivex.internal.operators.observable.ObservablePublishClassic, io.reactivex.internal.fuseable.HasUpstreamObservableSource
Type Parameters
<T>
the value type
Imports
java.util.concurrent.atomic.*, io.reactivex.*, io.reactivex.disposables.Disposable, io.reactivex.exceptions.Exceptions, io.reactivex.functions.Consumer, io.reactivex.internal.disposables.DisposableHelper, io.reactivex.internal.fuseable.HasUpstreamObservableSource, io.reactivex.internal.util.ExceptionHelper, io.reactivex.observables.ConnectableObservable, io.reactivex.plugins.RxJavaPlugins

A connectable observable which shares an underlying source and dispatches source values to observers in a backpressure-aware manner.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ObservablePublish.InnerDisposable<
the value type
T
>

A Disposable that manages the request and disposed state of a child Observer in thread-safe manner.

pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<ObservablePublish.PublishObserver<T>>
current

Holds the current subscriber that is, will be or just was subscribed to the source observable.

pack-priv final ObservableSource<T>
pack-priv final ObservableSource<T>
source

The source observable.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
connect(Consumer<? super Disposable>
the action that receives the connection subscription before the subscription to source happens allowing the caller to synchronously disconnect a synchronous source
connection
)

Implements abstract io.reactivex.observables.ConnectableObservable.connect.

Instructs the ConnectableObservable to begin emitting the items from its underlying Observable to its Observers.
public static <
the source value type
T
>
ConnectableObservable<T>

Returns:

the connectable observable
create
(ObservableSource<T>
the source observable
source
)

Creates a OperatorPublish instance to publish values of the given source observable.

public ObservableSource<T>
public ObservableSource<T>
source()

Implements io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Returns the upstream source of this Observable.
protected void
subscribeActual(Observer<? super T>
the incoming Observer, never null
observer
)

Implements abstract io.reactivex.Observable.subscribeActual.

Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.
Inherited from io.reactivex.observables.ConnectableObservable:
autoConnectautoConnectautoConnectconnectrefCountrefCountrefCountrefCountrefCountrefCount

Field Detail

currentback to summary
pack-priv final AtomicReference<ObservablePublish.PublishObserver<T>> current

Holds the current subscriber that is, will be or just was subscribed to the source observable.

onSubscribeback to summary
pack-priv final ObservableSource<T> onSubscribe
sourceback to summary
pack-priv final ObservableSource<T> source

The source observable.

Constructor Detail

ObservablePublishback to summary
private ObservablePublish(ObservableSource<T> onSubscribe, ObservableSource<T> source, final AtomicReference<ObservablePublish.PublishObserver<T>> current)

Method Detail

connectback to summary
public void connect(Consumer<? super Disposable> connection)

Implements abstract io.reactivex.observables.ConnectableObservable.connect.

Doc from io.reactivex.observables.ConnectableObservable.connect.

Instructs the ConnectableObservable to begin emitting the items from its underlying Observable to its Observers.

Parameters
connection:Consumer<? super Disposable>

the action that receives the connection subscription before the subscription to source happens allowing the caller to synchronously disconnect a synchronous source

Annotations
@Override
createback to summary
public static <T> ConnectableObservable<T> create(ObservableSource<T> source)

Creates a OperatorPublish instance to publish values of the given source observable.

Parameters
<T>
the source value type
source:ObservableSource<T>

the source observable

Returns:ConnectableObservable<T>

the connectable observable

publishSourceback to summary
public ObservableSource<T> publishSource()

Implements io.reactivex.internal.operators.observable.ObservablePublishClassic.publishSource.

Doc from io.reactivex.internal.operators.observable.ObservablePublishClassic.publishSource.

The upstream source of this publish operator.

Returns:ObservableSource<T>

the upstream source of this publish operator

Annotations
@Override
sourceback to summary
public ObservableSource<T> source()

Implements io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Doc from io.reactivex.internal.fuseable.HasUpstreamObservableSource.source.

Returns the upstream source of this Observable.

Allows discovering the chain of observables.

Returns:ObservableSource<T>

the source ObservableSource

Annotations
@Override
subscribeActualback to summary
protected void subscribeActual(Observer<? super T> observer)

Implements abstract io.reactivex.Observable.subscribeActual.

Doc from io.reactivex.Observable.subscribeActual.

Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.

There is no need to call any of the plugin hooks on the current Observable instance or the Observer; all hooks and basic safeguards have been applied by subscribe(Observer) before this method gets called.

Parameters
observer:Observer<? super T>

the incoming Observer, never null

Annotations
@Override
io.reactivex.internal.operators.observable back to summary

pack-priv final Class ObservablePublish.InnerDisposable<T>

extends AtomicReference<Object>
implements Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable
Type Parameters
<T>
the value type

A Disposable that manages the request and disposed state of a child Observer in thread-safe manner. this holds the parent PublishObserver or itself if disposed

Field Summary

Modifier and TypeField and Description
pack-priv final Observer<? super T>
child

The actual child subscriber.

private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
InnerDisposable(Observer<? super T> child)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
pack-priv void
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

childback to summary
pack-priv final Observer<? super T> child

The actual child subscriber.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

Constructor Detail

InnerDisposableback to summary
pack-priv InnerDisposable(Observer<? super T> child)

Method Detail

disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@SuppressWarnings:unchecked
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
setParentback to summary
pack-priv void setParent(ObservablePublish.PublishObserver<T> p)
io.reactivex.internal.operators.observable back to summary

pack-priv final Class ObservablePublish.PublishObserver<T>

extends Object
implements Observer<T>, Disposable
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.operators.observable.ObservablePublish.PublishObserver
All Implemented Interfaces
io.reactivex.disposables.Disposable, io.reactivex.Observer
Annotations
@SuppressWarnings:rawtypes

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<ObservablePublish.PublishObserver<T>>
current

Holds onto the current connected PublishObserver.

pack-priv static final ObservablePublish.InnerDisposable<T>[]
EMPTY

Indicates an empty array of inner observers.

pack-priv final AtomicReference<ObservablePublish.InnerDisposable<T>[]>
observers

Tracks the subscribed observers.

pack-priv final AtomicBoolean
shouldConnect

Atomically changed from false to true by connect to make sure the connection is only performed by one thread.

pack-priv static final ObservablePublish.InnerDisposable<T>[]
TERMINATED

Indicates a terminated PublishObserver.

pack-priv final AtomicReference<Disposable>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean

Returns:

true if succeeded, false otherwise
add
(ObservablePublish.InnerDisposable<T>
the producer to add
producer
)

Atomically try adding a new InnerDisposable to this Observer or return false if this Observer was terminated.

public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public void
onComplete()

Implements io.reactivex.Observer.onComplete.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements io.reactivex.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements io.reactivex.Observer.onNext.

Provides the Observer with a new item to observe.
public void
onSubscribe(Disposable
the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection
d
)

Implements io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.
pack-priv void
remove(ObservablePublish.InnerDisposable<T>
the producer to remove
producer
)

Atomically removes the given producer from the observers array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
pack-priv final AtomicReference<ObservablePublish.PublishObserver<T>> current

Holds onto the current connected PublishObserver.

EMPTYback to summary
pack-priv static final ObservablePublish.InnerDisposable<T>[] EMPTY

Indicates an empty array of inner observers.

observersback to summary
pack-priv final AtomicReference<ObservablePublish.InnerDisposable<T>[]> observers

Tracks the subscribed observers.

shouldConnectback to summary
pack-priv final AtomicBoolean shouldConnect

Atomically changed from false to true by connect to make sure the connection is only performed by one thread.

TERMINATEDback to summary
pack-priv static final ObservablePublish.InnerDisposable<T>[] TERMINATED

Indicates a terminated PublishObserver.

upstreamback to summary
pack-priv final AtomicReference<Disposable> upstream

Constructor Detail

PublishObserverback to summary
pack-priv PublishObserver(AtomicReference<ObservablePublish.PublishObserver<T>> current)
Annotations
@SuppressWarnings:unchecked

Method Detail

addback to summary
pack-priv boolean add(ObservablePublish.InnerDisposable<T> producer)

Atomically try adding a new InnerDisposable to this Observer or return false if this Observer was terminated.

Parameters
producer:ObservablePublish.InnerDisposable<T>

the producer to add

Returns:boolean

true if succeeded, false otherwise

disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@SuppressWarnings:unchecked
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements io.reactivex.Observer.onComplete.

Doc from io.reactivex.Observer.onComplete.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@SuppressWarnings:unchecked
@Override
onErrorback to summary
public void onError(Throwable e)

Implements io.reactivex.Observer.onError.

Doc from io.reactivex.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onComplete.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@SuppressWarnings:unchecked
@Override
onNextback to summary
public void onNext(T t)

Implements io.reactivex.Observer.onNext.

Doc from io.reactivex.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onComplete or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(Disposable d)

Implements io.reactivex.Observer.onSubscribe.

Doc from io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.

Parameters
d:Disposable

the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection

Annotations
@Override
removeback to summary
pack-priv void remove(ObservablePublish.InnerDisposable<T> producer)

Atomically removes the given producer from the observers array.

Parameters
producer:ObservablePublish.InnerDisposable<T>

the producer to remove

Annotations
@SuppressWarnings:unchecked
io.reactivex.internal.operators.observable back to summary

pack-priv final Class ObservablePublish.PublishSource<T>

extends Object
implements ObservableSource<T>
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.operators.observable.ObservablePublish.PublishSource
All Implemented Interfaces
io.reactivex.ObservableSource

Field Summary

Modifier and TypeField and Description
private final AtomicReference<ObservablePublish.PublishObserver<T>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
subscribe(Observer<? super T>
the Observer, not null
child
)

Implements io.reactivex.ObservableSource.subscribe.

Subscribes the given Observer to this ObservableSource instance.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currback to summary
private final AtomicReference<ObservablePublish.PublishObserver<T>> curr

Constructor Detail

PublishSourceback to summary
pack-priv PublishSource(AtomicReference<ObservablePublish.PublishObserver<T>> curr)

Method Detail

subscribeback to summary
public void subscribe(Observer<? super T> child)

Implements io.reactivex.ObservableSource.subscribe.

Doc from io.reactivex.ObservableSource.subscribe.

Subscribes the given Observer to this ObservableSource instance.

Parameters
child:Observer<? super T>

the Observer, not null

Annotations
@Override