![JAR search and dependency download from the Maven repository](/logo.png)
mutiny.zero.internal.LatestTube Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mutiny-zero Show documentation
Show all versions of mutiny-zero Show documentation
Mutiny Zero is a minimal API for creating reactive-streams compliant publishers
package mutiny.zero.internal;
import java.util.Queue;
import java.util.concurrent.Flow;
import java.util.concurrent.LinkedBlockingDeque;
public class LatestTube extends BufferingTubeBase {
private final LinkedBlockingDeque overflowQueue;
public LatestTube(Flow.Subscriber super T> subscriber, int bufferSize) {
super(subscriber);
overflowQueue = new LinkedBlockingDeque<>(bufferSize);
}
@Override
Queue overflowQueue() {
return overflowQueue;
}
@Override
protected void handleItem(T item) {
if (outstandingRequests() > 0L) {
dispatchQueue.offer(item);
drainLoop();
} else if (!overflowQueue.offer(item)) {
overflowQueue.remove();
overflowQueue.offer(item);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy