/** * Build a {@literal Broadcaster}, rfirst broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link reactor.rx.action * .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 <T> the type of values passing through the {@literal action} * @return a new {@link reactor.rx.action.Action} */ public static <T> Broadcaster<T> first(T value) { return new BehaviorBroadcaster<>(null, SynchronousDispatcher.INSTANCE, Long.MAX_VALUE, value); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * 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> first(T value, Environment env, Dispatcher dispatcher) { Assert.state(dispatcher.supportsOrdering(), "Dispatcher provided doesn't support event ordering. " + " For concurrent consume, refer to Stream#partition/groupBy() method and assign individual single " + "dispatchers"); return new BehaviorBroadcaster<>(env, dispatcher, Action.evaluateCapacity(dispatcher.backlogSize()), value); }
/** * Build a {@literal Broadcaster}, rfirst broadcasting the most recent signal then starting with the passed value, * then ready to broadcast values with {@link reactor.rx.action * .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 <T> the type of values passing through the {@literal action} * @return a new {@link reactor.rx.action.Action} */ public static <T> Broadcaster<T> first(T value) { return new BehaviorBroadcaster<>(null, SynchronousDispatcher.INSTANCE, Long.MAX_VALUE, value); }
/** * Build a {@literal Broadcaster}, first broadcasting the most recent signal then starting with the passed value, * 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> first(T value, Environment env, Dispatcher dispatcher) { Assert.state(dispatcher.supportsOrdering(), "Dispatcher provided doesn't support event ordering. " + " For concurrent consume, refer to Stream#partition/groupBy() method and assign individual single " + "dispatchers"); return new BehaviorBroadcaster<>(env, dispatcher, Action.evaluateCapacity(dispatcher.backlogSize()), value); }