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

mutiny.zero.internal.UnbounbedBufferingTube Maven / Gradle / Ivy

package mutiny.zero.internal;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

import org.reactivestreams.Subscriber;

public class UnbounbedBufferingTube extends BufferingTubeBase {

    private final ConcurrentLinkedQueue overflowQueue;

    public UnbounbedBufferingTube(Subscriber subscriber) {
        super(subscriber, -1);
        overflowQueue = new ConcurrentLinkedQueue<>();
    }

    @Override
    Queue overflowQueue() {
        return overflowQueue;
    }

    @Override
    protected void handleItem(T item) {
        if (outstandingRequests() > 0L) {
            dispatchQueue.offer(item);
            drainLoop();
        } else {
            overflowQueue.offer(item);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy