Package org.reactivestreams

Examples of org.reactivestreams.Subscription


    if (subscription == null) {
      return outboundStream;
    }

    Subscription sub = subscription;
    Action<?, ?> that = null;

    while (sub != null
        && PushSubscription.class.isAssignableFrom(sub.getClass())
        && ((PushSubscription<?>) sub).getPublisher() != null
        && Action.class.isAssignableFrom(((PushSubscription<?>) sub).getPublisher().getClass())
        ) {

      that = (Action<?, ?>) ((PushSubscription<?>) sub).getPublisher();
View Full Code Here


  }

  @Override
  public void subscribe(final Subscriber<? super Long> subscriber) {
    if(upstreamSubscription != null && upstreamSubscription.isComplete()){
      subscriber.onSubscribe(new Subscription() {
        @Override
        public void request(long n) {
          subscriber.onNext(counter.get());
          subscriber.onComplete();
        }
View Full Code Here

  public void subscribe(final Subscriber<? super T> downstream) {
    final GatedSubscriber<? super T> gatedSubscriber = new GatedSubscriber<>(downstream);
    try {
      releaseReceiver.execute((Runnable) gatedSubscriber::open);
    } catch (final Throwable e) {
      downstream.onSubscribe(new Subscription() {
        @Override
        public void request(long n) {
          downstream.onError(e);
        }
View Full Code Here

  @Override
  public void subscribe(final Subscriber<? super T> downStreamSubscriber) {
    if (upstreamFinished.get()) {
      downStreamSubscriber.onError(new IllegalStateException("The upstream publisher has completed, either successfully or with error.  No further subscriptions will be accepted"));
    } else {
      buffer((Publisher<T>) s -> s.onSubscribe(new Subscription() {
        @Override
        public void request(long n) {
          bufferedSubscribers.add(s);
          tryUpstreamSubscribe();
        }
View Full Code Here

    this.timeUnit = timeUnit;
  }

  @Override
  public void subscribe(final Subscriber<? super T> s) {
    s.onSubscribe(new Subscription() {
      private final AtomicInteger counter = new AtomicInteger(0);
      private final ScheduledFuture<?> future = executorService.scheduleWithFixedDelay(() -> {
        int i = counter.getAndIncrement();
        T value;
        try {
View Full Code Here

          }
        }
      });
    }

    subscriber.onSubscribe(new Subscription() {
      @Override
      public void request(long n) {
        for (Subscription upstreamPublisherSubscription : upstreamPublisherSubscriptions) {
          upstreamPublisherSubscription.request(n);
        }
View Full Code Here

      private final AtomicBoolean done = new AtomicBoolean();

      @Override
      public void onSubscribe(final Subscription subscription) {
        this.subscription = subscription;
        outSubscriber.onSubscribe(new Subscription() {
          @Override
          public void request(long n) {
            try {
              listener.execute(new RequestEvent<>(subscriptionId, n));
            } catch (Throwable throwable) {
View Full Code Here

*/
public class StockPricePublisher implements Publisher<Stock> {

    @Override
    public void subscribe(final Subscriber<? super Stock> s) {
        s.onSubscribe(new Subscription() {

            AtomicLong capacity = new AtomicLong();
            EventHandler handler = new EventHandler(s, capacity);

            @Override
View Full Code Here

  @Required @Test
  public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable {
    subscriberTestWithoutSetup(new TestStageTestRun() {
      @Override
      public void run(WhiteboxTestStage stage) throws Throwable {
        final Subscription subs = new Subscription() {
          @Override
          public void request(long n) {
            Throwable thr = new Throwable();
            for (StackTraceElement stackTraceElement : thr.getStackTrace()) {
              if (stackTraceElement.getMethodName().equals("onComplete")) {
View Full Code Here

  @Required @Test
  public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable {
    subscriberTestWithoutSetup(new TestStageTestRun() {
      @Override
      public void run(WhiteboxTestStage stage) throws Throwable {
        final Subscription subs = new Subscription() {
          @Override
          public void request(long n) {
            Throwable thr = new Throwable();
            for (StackTraceElement stackTraceElement : thr.getStackTrace()) {
              if (stackTraceElement.getMethodName().equals("onError")) {
View Full Code Here

TOP

Related Classes of org.reactivestreams.Subscription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.