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 2016 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.*;
import rx.functions.Func1;
import rx.internal.util.*;
import rx.internal.util.atomic.*;
import rx.internal.util.unsafe.*;
import rx.plugins.RxJavaHooks;
/**
* Flattens a sequence if Iterable sources, generated via a function, into a single sequence.
*
* @param the input value type
* @param the output value type
*/
public final class OnSubscribeFlattenIterable implements OnSubscribe {
final Observable extends T> source;
final Func1 super T, ? extends Iterable extends R>> mapper;
final int prefetch;
/** Protected: use createFrom to handle source-dependent optimizations. */
protected OnSubscribeFlattenIterable(Observable extends T> source,
Func1 super T, ? extends Iterable extends R>> mapper, int prefetch) {
this.source = source;
this.mapper = mapper;
this.prefetch = prefetch;
}
@Override
public void call(Subscriber super R> t) {
final FlattenIterableSubscriber parent = new FlattenIterableSubscriber(t, mapper, prefetch);
t.add(parent);
t.setProducer(new Producer() {
@Override
public void request(long n) {
parent.requestMore(n);
}
});
source.unsafeSubscribe(parent);
}
public static Observable createFrom(Observable extends T> source,
Func1 super T, ? extends Iterable extends R>> mapper, int prefetch) {
if (source instanceof ScalarSynchronousObservable) {
T scalar = ((ScalarSynchronousObservable extends T>) source).get();
return Observable.create(new OnSubscribeScalarFlattenIterable(scalar, mapper));
}
return Observable.create(new OnSubscribeFlattenIterable(source, mapper, prefetch));
}
static final class FlattenIterableSubscriber extends Subscriber {
final Subscriber super R> actual;
final Func1 super T, ? extends Iterable extends R>> mapper;
final long limit;
final Queue