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) 2011-2017 Pivotal Software Inc, 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
*
* http://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.TimeUnit;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.stream.Stream;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Disposable;
import reactor.core.Disposables;
import reactor.core.Exceptions;
import reactor.core.Scannable;
import reactor.core.scheduler.Scheduler;
import reactor.util.concurrent.Queues;
/**
* @author David Karnok
*/
final class FluxWindowTimeout extends FluxOperator> {
final int maxSize;
final long timespan;
final Scheduler timer;
FluxWindowTimeout(Flux source, int maxSize, long timespan, Scheduler timer) {
super(source);
if (timespan <= 0) {
throw new IllegalArgumentException("Timeout period must be strictly positive");
}
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize must be strictly positive");
}
this.timer = Objects.requireNonNull(timer, "Timer");
this.timespan = timespan;
this.maxSize = maxSize;
}
@Override
public void subscribe(CoreSubscriber super Flux> actual) {
source.subscribe(new WindowTimeoutSubscriber<>(actual, maxSize,
timespan,
timer));
}
static final class WindowTimeoutSubscriber implements InnerOperator> {
final CoreSubscriber super Flux> actual;
final long timespan;
final Scheduler scheduler;
final int maxSize;
final Scheduler.Worker worker;
final Queue