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;
import java.util.Queue;
import java.util.concurrent.atomic.*;
import org.reactivestreams.*;
import hu.akarnokd.rxjava2.Observable.Operator;
import hu.akarnokd.rxjava2.functions.Function;
import hu.akarnokd.rxjava2.internal.queue.*;
import hu.akarnokd.rxjava2.internal.subscriptions.SubscriptionHelper;
import hu.akarnokd.rxjava2.internal.util.*;
import hu.akarnokd.rxjava2.plugins.RxJavaPlugins;
public final class OperatorSwitchMap implements Operator {
final Function super T, ? extends Publisher extends R>> mapper;
final int bufferSize;
public OperatorSwitchMap(Function super T, ? extends Publisher extends R>> mapper, int bufferSize) {
this.mapper = mapper;
this.bufferSize = bufferSize;
}
@Override
public Subscriber super T> apply(Subscriber super R> t) {
return new SwitchMapSubscriber(t, mapper, bufferSize);
}
static final class SwitchMapSubscriber extends AtomicInteger implements Subscriber, Subscription {
/** */
private static final long serialVersionUID = -3491074160481096299L;
final Subscriber super R> actual;
final Function super T, ? extends Publisher extends R>> mapper;
final int bufferSize;
volatile boolean done;
Throwable error;
volatile boolean cancelled;
Subscription s;
volatile SwitchMapInnerSubscriber active;
@SuppressWarnings("rawtypes")
static final AtomicReferenceFieldUpdater ACTIVE =
AtomicReferenceFieldUpdater.newUpdater(SwitchMapSubscriber.class, SwitchMapInnerSubscriber.class, "active");
volatile long requested;
@SuppressWarnings("rawtypes")
static final AtomicLongFieldUpdater REQUESTED =
AtomicLongFieldUpdater.newUpdater(SwitchMapSubscriber.class, "requested");
static final SwitchMapInnerSubscriber