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

net.pincette.rs.Split Maven / Gradle / Ivy

There is a newer version: 3.7.1
Show newest version
package net.pincette.rs;

import java.util.concurrent.Flow.Processor;

/**
 * When the upstream or downstream could cause races, this processor serializes everything. It uses
 * a shared thread.
 *
 * @param  the value type.
 * @author Werner Donn\u00e9
 * @since 3.0
 */
public class Split extends ProcessorBase {
  public static  Processor split() {
    return new Split<>();
  }

  @Override
  protected void emit(long number) {
    dispatch(() -> subscription.request(number));
  }

  @Override
  public void onComplete() {
    dispatch(super::onComplete);
  }

  @Override
  public void onError(Throwable t) {
    dispatch(() -> super.onError(t));
  }

  @Override
  public void onNext(T value) {
    dispatch(() -> subscriber.onNext(value));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy