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.asPublisherneeds to offer aPublisherthat 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
Publishermust not retain a reference to theSubscriberafter having hooked it up with the realPublisher, hence the use ofInert.subscriberas 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 voidregisterPublisher(org.reactivestreams.Publisher<?> pub)voidsubscribe(org.reactivestreams.Subscriber<? super T> subscriber)java.lang.StringtoString()-
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:
subscribein interfaceorg.reactivestreams.Publisher<T>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.concurrent.atomic.AtomicReference<java.lang.Object>
-
-