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 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 rx.internal.operators;
import java.util.*;
import java.util.concurrent.atomic.*;
import rx.*;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.exceptions.CompositeException;
import rx.functions.FuncN;
import rx.internal.util.RxRingBuffer;
import rx.internal.util.atomic.SpscLinkedArrayQueue;
import rx.plugins.RxJavaHooks;
public final class OnSubscribeCombineLatest implements OnSubscribe {
final Observable extends T>[] sources;
final Iterable extends Observable extends T>> sourcesIterable;
final FuncN extends R> combiner;
final int bufferSize;
final boolean delayError;
public OnSubscribeCombineLatest(Iterable extends Observable extends T>> sourcesIterable,
FuncN extends R> combiner) {
this(null, sourcesIterable, combiner, RxRingBuffer.SIZE, false);
}
public OnSubscribeCombineLatest(Observable extends T>[] sources,
Iterable extends Observable extends T>> sourcesIterable,
FuncN 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", "rawtypes" })
public void call(Subscriber super R> s) {
Observable extends T>[] sources = this.sources;
int count = 0;
if (sources == null) {
if (sourcesIterable instanceof List) {
// unchecked & raw: javac type inference problem otherwise
List list = (List)sourcesIterable;
sources = (Observable[])list.toArray(new Observable[list.size()]);
count = sources.length;
} else {
sources = new Observable[8];
for (Observable extends T> p : sourcesIterable) {
if (count == sources.length) {
Observable extends T>[] b = new Observable[count + (count >> 2)];
System.arraycopy(sources, 0, b, 0, count);
sources = b;
}
sources[count++] = p;
}
}
} else {
count = sources.length;
}
if (count == 0) {
s.onCompleted();
return;
}
LatestCoordinator lc = new LatestCoordinator(s, combiner, count, bufferSize, delayError);
lc.subscribe(sources);
}
static final class LatestCoordinator extends AtomicInteger implements Producer, Subscription {
/** */
private static final long serialVersionUID = 8567835998786448817L;
final Subscriber super R> actual;
final FuncN extends R> combiner;
final CombinerSubscriber[] subscribers;
final int bufferSize;
final Object[] latest;
final SpscLinkedArrayQueue