Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2016-2023 VMware Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.core.publisher;
import java.util.Objects;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Disposable;
import reactor.core.Exceptions;
import reactor.core.Scannable;
import reactor.util.annotation.Nullable;
import reactor.util.concurrent.Queues;
import reactor.util.context.Context;
import static reactor.core.Exceptions.wrapSource;
/**
* Splits the source sequence into continuous, non-overlapping windowEnds
* where the window boundary is signalled by another Publisher
*
* @param the input value type
* @param the boundary publisher's type (irrelevant)
* @see Reactive-Streams-Commons
*/
final class FluxWindowBoundary extends InternalFluxOperator> {
final Publisher other;
final Supplier extends Queue> processorQueueSupplier;
FluxWindowBoundary(Flux extends T> source, Publisher other,
Supplier extends Queue> processorQueueSupplier) {
super(source);
this.other = Operators.toFluxOrMono(Objects.requireNonNull(other, "other"));
this.processorQueueSupplier = Objects.requireNonNull(processorQueueSupplier, "processorQueueSupplier");
}
@Override
public int getPrefetch() {
return Integer.MAX_VALUE;
}
@Override
@Nullable
public CoreSubscriber super T> subscribeOrReturn(CoreSubscriber super Flux> actual) {
WindowBoundaryMain main = new WindowBoundaryMain<>(actual,
processorQueueSupplier, processorQueueSupplier.get());
actual.onSubscribe(main);
if (main.emit(main.window)) {
other.subscribe(main.boundary);
return main;
}
else {
return null;
}
}
@Override
public Object scanUnsafe(Attr key) {
if (key == Attr.RUN_STYLE) return Attr.RunStyle.SYNC;
return super.scanUnsafe(key);
}
static final class WindowBoundaryMain
implements InnerOperator>, Disposable {
final Supplier extends Queue> processorQueueSupplier;
final WindowBoundaryOther boundary;
final Queue