All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.salesforce.rxgrpc.stub.RxServerStreamObserverAndPublisher Maven / Gradle / Ivy

There is a newer version: 1.2.4
Show newest version
/*
 *  Copyright (c) 2019, Salesforce.com, Inc.
 *  All rights reserved.
 *  Licensed under the BSD 3-Clause license.
 *  For full license text, see LICENSE.txt file in the repo root  or https://opensource.org/licenses/BSD-3-Clause
 */

package com.salesforce.rxgrpc.stub;

import com.salesforce.reactivegrpc.common.AbstractServerStreamObserverAndPublisher;
import com.salesforce.reactivegrpc.common.Consumer;
import io.grpc.stub.CallStreamObserver;
import io.grpc.stub.ServerCallStreamObserver;
import io.reactivex.internal.fuseable.QueueFuseable;
import io.reactivex.internal.fuseable.QueueSubscription;
import io.reactivex.internal.queue.SpscArrayQueue;

/**
 * TODO: Explain what this class does.
 * @param  T
 */
class RxServerStreamObserverAndPublisher
        extends AbstractServerStreamObserverAndPublisher
        implements QueueSubscription {

    RxServerStreamObserverAndPublisher(
            ServerCallStreamObserver serverCallStreamObserver,
            Consumer> onSubscribe) {
        super(serverCallStreamObserver, new SimpleQueueAdapter(new SpscArrayQueue(DEFAULT_CHUNK_SIZE)), onSubscribe);
    }

    @Override
    public int requestFusion(int requestedMode) {
        if ((requestedMode & QueueFuseable.ASYNC) != 0) {
            outputFused = true;
            return QueueFuseable.ASYNC;
        }
        return QueueFuseable.NONE;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy