Class VirtualPublisher<T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<java.lang.Object>
-
- akka.stream.impl.VirtualPublisher<T>
-
- All Implemented Interfaces:
java.io.Serializable
,org.reactivestreams.Publisher<T>
public class VirtualPublisher<T> extends java.util.concurrent.atomic.AtomicReference<java.lang.Object> implements org.reactivestreams.Publisher<T>
INTERNAL APIThe implementation of
Sink.asPublisher
needs to offer aPublisher
that defers to the upstream that is connected during materialization. This would be trivial if it were not for materialized value computations that may even spawn the code that doespub.subscribe(sub)
in a Future, running concurrently with the actual materialization. Therefore we implement a minimal shell here that plugs the downstream and the upstream together as soon as both are known. Using a VirtualProcessor would technically also work, but it would defeat the purpose of subscription timeouts—the subscription would always already be established from the Actor’s perspective, regardless of whether a downstream will ever be connected.One important consideration is that this
Publisher
must not retain a reference to theSubscriber
after having hooked it up with the realPublisher
, hence the use ofInert.subscriber
as a tombstone.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VirtualPublisher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
registerPublisher(org.reactivestreams.Publisher<?> pub)
void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
java.lang.String
toString()
-
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Method Detail
-
registerPublisher
public final void registerPublisher(org.reactivestreams.Publisher<?> pub)
-
subscribe
public void subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
- Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<T>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.concurrent.atomic.AtomicReference<java.lang.Object>
-
-