protected Stream<T> createWindowStream(T first) { Broadcaster<T> action = BehaviorBroadcaster.first(first, environment, dispatcher); windowBroadcaster = action; return action; }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then ready to broadcast values with * {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Dispatcher dispatcher) { return first(null, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> first(T value, Dispatcher dispatcher) { return first(value, null, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then * ready to broadcast values with {@link Broadcaster#onNext * (Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param env the Reactor {@link reactor.Environment} to use * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Stream} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Environment env, Dispatcher dispatcher) { return first(null, env, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then ready to broadcast values with * {@link * reactor.rx.broadcast.Broadcaster#onNext(Object)}, * {@link reactor.rx.broadcast.Broadcaster#onError(Throwable)}, {@link reactor.rx.broadcast.Broadcaster#onComplete * ()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * <p> * A serialized broadcaster will make sure that even in a multhithreaded scenario, only one thread will be able to * broadcast at a time. * The synchronization is non blocking for the publisher, using thread-stealing and first-in-first-served patterns. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link reactor.rx.broadcast.Broadcaster} */ public static <T> Broadcaster<T> create(Environment env) { return first(null, env); }
protected Broadcaster<T> createWindowStream(T first) { Broadcaster<T> action = BehaviorBroadcaster.first(first, environment, dispatcher); currentWindows.add(action); broadcastNext(action); return action; }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link * reactor.rx.broadcast.Broadcaster#onNext(Object)}, * {@link reactor.rx.broadcast.Broadcaster#onError(Throwable)}, {@link reactor.rx.broadcast.Broadcaster#onComplete * ()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * <p> * A serialized broadcaster will make sure that even in a multhithreaded scenario, only one thread will be able to * broadcast at a time. * The synchronization is non blocking for the publisher, using thread-stealing and first-in-first-served patterns. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link reactor.rx.broadcast.Broadcaster} */ public static <T> Broadcaster<T> first(T value, Environment env) { return first(value, env, env.getDefaultDispatcher()); }
public Stream<O> stream() { lock.lock(); try { if (outboundStream == null) { outboundStream = BehaviorBroadcaster.first(value, environment, dispatcher).capacity(1); if (isSuccess()) { outboundStream.onComplete(); } else if (isError()) { outboundStream.onError(error); } } } finally { lock.unlock(); } return outboundStream; }
protected Stream<T> createWindowStream(T first) { Broadcaster<T> action = BehaviorBroadcaster.first(first, environment, dispatcher); windowBroadcaster = action; return action; }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then ready to broadcast values with * {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Dispatcher dispatcher) { return first(null, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> first(T value, Dispatcher dispatcher) { return first(value, null, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then * ready to broadcast values with {@link Broadcaster#onNext * (Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param env the Reactor {@link reactor.Environment} to use * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Stream} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Environment env, Dispatcher dispatcher) { return first(null, env, dispatcher); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then ready to broadcast values with * {@link * reactor.rx.broadcast.Broadcaster#onNext(Object)}, * {@link reactor.rx.broadcast.Broadcaster#onError(Throwable)}, {@link reactor.rx.broadcast.Broadcaster#onComplete * ()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * <p> * A serialized broadcaster will make sure that even in a multhithreaded scenario, only one thread will be able to * broadcast at a time. * The synchronization is non blocking for the publisher, using thread-stealing and first-in-first-served patterns. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link reactor.rx.broadcast.Broadcaster} */ public static <T> Broadcaster<T> create(Environment env) { return first(null, env); }
protected Broadcaster<T> createWindowStream(T first) { Broadcaster<T> action = BehaviorBroadcaster.first(first, environment, dispatcher); currentWindows.add(action); broadcastNext(action); return action; }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link * reactor.rx.broadcast.Broadcaster#onNext(Object)}, * {@link reactor.rx.broadcast.Broadcaster#onError(Throwable)}, {@link reactor.rx.broadcast.Broadcaster#onComplete * ()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * <p> * A serialized broadcaster will make sure that even in a multhithreaded scenario, only one thread will be able to * broadcast at a time. * The synchronization is non blocking for the publisher, using thread-stealing and first-in-first-served patterns. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link reactor.rx.broadcast.Broadcaster} */ public static <T> Broadcaster<T> first(T value, Environment env) { return first(value, env, env.getDefaultDispatcher()); }
public Stream<O> stream() { lock.lock(); try { if (outboundStream == null) { outboundStream = BehaviorBroadcaster.first(value, environment, dispatcher).capacity(1); if (isSuccess()) { outboundStream.onComplete(); } else if (isError()) { outboundStream.onError(error); } } } finally { lock.unlock(); } return outboundStream; }