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 2015 David Karnok and Netflix, Inc.
*
* 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 hu.akarnokd.rxjava2.internal.operators.nbp;
import java.util.*;
import java.util.concurrent.atomic.*;
import hu.akarnokd.rxjava2.NbpObservable;
import hu.akarnokd.rxjava2.NbpObservable.*;
import hu.akarnokd.rxjava2.disposables.Disposable;
import hu.akarnokd.rxjava2.exceptions.CompositeException;
import hu.akarnokd.rxjava2.functions.Function;
import hu.akarnokd.rxjava2.internal.disposables.EmptyDisposable;
import hu.akarnokd.rxjava2.internal.queue.SpscLinkedArrayQueue;
import hu.akarnokd.rxjava2.internal.subscriptions.SubscriptionHelper;
import hu.akarnokd.rxjava2.plugins.RxJavaPlugins;
public final class NbpOnSubscribeCombineLatest implements NbpOnSubscribe {
final NbpObservable extends T>[] sources;
final Iterable extends NbpObservable extends T>> sourcesIterable;
final Function super Object[], ? extends R> combiner;
final int bufferSize;
final boolean delayError;
public NbpOnSubscribeCombineLatest(NbpObservable extends T>[] sources,
Iterable extends NbpObservable extends T>> sourcesIterable,
Function super Object[], ? extends R> combiner, int bufferSize,
boolean delayError) {
this.sources = sources;
this.sourcesIterable = sourcesIterable;
this.combiner = combiner;
this.bufferSize = bufferSize;
this.delayError = delayError;
}
@Override
@SuppressWarnings("unchecked")
public void accept(NbpSubscriber super R> s) {
NbpObservable extends T>[] sources = this.sources;
int count = 0;
if (sources == null) {
sources = new NbpObservable[8];
for (NbpObservable extends T> p : sourcesIterable) {
if (count == sources.length) {
NbpObservable extends T>[] b = new NbpObservable[count + (count >> 2)];
System.arraycopy(sources, 0, b, 0, count);
sources = b;
}
sources[count++] = p;
}
} else {
count = sources.length;
}
if (count == 0) {
EmptyDisposable.complete(s);
return;
}
LatestCoordinator lc = new LatestCoordinator(s, combiner, count, bufferSize, delayError);
lc.subscribe(sources);
}
static final class LatestCoordinator extends AtomicInteger implements Disposable {
/** */
private static final long serialVersionUID = 8567835998786448817L;
final NbpSubscriber super R> actual;
final Function super Object[], ? extends R> combiner;
final int count;
final CombinerSubscriber[] subscribers;
final int bufferSize;
final Object[] latest;
final SpscLinkedArrayQueue