/** * Zip two sources together, that is to say wait for all the sources to emit one * element and combine these elements once into an output value (constructed by the provided * combinator). The operator will continue doing so until any of the sources completes. * Errors will immediately be forwarded. * This "Step-Merge" processing is especially useful in Scatter-Gather scenarios. * <p> * <img class="marble" src="doc-files/marbles/zipTwoSourcesWithZipperForFlux.svg" alt=""> * * @param source1 The first {@link Publisher} source to zip. * @param source2 The second {@link Publisher} source to zip. * @param combinator The aggregate function that will receive a unique value from each upstream and return the * value to signal downstream * @param <T1> type of the value from source1 * @param <T2> type of the value from source2 * @param <O> The produced output after transformation by the combinator * * @return a zipped {@link Flux} */ public static <T1, T2, O> Flux<O> zip(Publisher<? extends T1> source1, Publisher<? extends T2> source2, final BiFunction<? super T1, ? super T2, ? extends O> combinator) { return onAssembly(new FluxZip<T1, O>(source1, source2, combinator, Queues.xs(), Queues.XS_BUFFER_SIZE)); }
@Test public void spscArrayQueuesAPI() { assertThat(Queues.xs().get()).isInstanceOf(SpscArrayQueue.class); }
/** * Zip two sources together, that is to say wait for all the sources to emit one * element and combine these elements once into an output value (constructed by the provided * combinator). The operator will continue doing so until any of the sources completes. * Errors will immediately be forwarded. * This "Step-Merge" processing is especially useful in Scatter-Gather scenarios. * <p> * <img class="marble" src="doc-files/marbles/zipTwoSourcesWithZipperForFlux.svg" alt=""> * * @param source1 The first {@link Publisher} source to zip. * @param source2 The second {@link Publisher} source to zip. * @param combinator The aggregate function that will receive a unique value from each upstream and return the * value to signal downstream * @param <T1> type of the value from source1 * @param <T2> type of the value from source2 * @param <O> The produced output after transformation by the combinator * * @return a zipped {@link Flux} */ public static <T1, T2, O> Flux<O> zip(Publisher<? extends T1> source1, Publisher<? extends T2> source2, final BiFunction<? super T1, ? super T2, ? extends O> combinator) { return onAssembly(new FluxZip<T1, O>(source1, source2, combinator, Queues.xs(), Queues.XS_BUFFER_SIZE)); }