コード例 #1
0
  @Override
  public void subscribe(Subscriber<? super T> s) {
    Consumer<Runnable> scheduler;

    try {
      scheduler = schedulerFactory.call();
    } catch (Throwable e) {
      Exceptions.throwIfFatal(e);
      EmptySubscription.error(s, e);
      return;
    }

    if (scheduler == null) {
      EmptySubscription.error(
          s, new NullPointerException("The schedulerFactory returned a null Function"));
      return;
    }

    if (value == null) {
      FluxPublishOn.ScheduledEmptySubscriptionEager parent =
          new FluxPublishOn.ScheduledEmptySubscriptionEager(s, scheduler);
      s.onSubscribe(parent);
      scheduler.accept(parent);
    } else {
      s.onSubscribe(new FluxPublishOn.ScheduledSubscriptionEagerCancel<>(s, value, scheduler));
    }
  }
コード例 #2
0
  @Override
  public void subscribe(final Subscriber<? super T> subscriber) {
    try {
      if (supplier != null) {
        subscriber.onSubscribe(
            new PushSubscription<T>(this, subscriber) {

              @Override
              public void request(long elements) {
                try {
                  supplyValue(subscriber);
                } catch (Throwable throwable) {
                  subscriber.onError(throwable);
                }
              }
            });

      } else {
        subscriber.onComplete();
      }
    } catch (Throwable throwable) {
      Exceptions.throwIfFatal(throwable);
      subscriber.onError(throwable);
    }
  }
コード例 #3
0
  @Override
  public void subscribe(Subscriber<? super Object> s) {
    if (log.isDebugEnabled()) {
      log.debug(
          "Subscribing inbound receiver [pending: "
              + ""
              + inboundEmitter.getPending()
              + ", done: "
              + inboundEmitter.done
              + "]");
    }
    if (inboundEmitter.actual == null) {
      if (inboundEmitter.done) {
        if (inboundEmitter.error != null) {
          Operators.error(s, inboundEmitter.error);
          return;
        } else if (inboundEmitter.getPending() == 0) {
          Operators.complete(s);
          return;
        }
      }

      inboundEmitter.init(s);
      s.onSubscribe(inboundEmitter);
    } else {
      Operators.error(
          s, new IllegalStateException("Only one connection receive subscriber allowed."));
    }
  }
コード例 #4
0
  @Override
  public void subscribe(Subscriber<? super Long> s) {
    PublisherTimerRunnable r = new PublisherTimerRunnable(s, asyncExecutor);

    s.onSubscribe(r);

    r.setCancel(asyncExecutor.apply(r));
  }
コード例 #5
0
 @Override
 public void onSubscribe(Subscription s) {
   if (SubscriptionHelper.validateSubscription(this.s, s)) {
     return;
   }
   this.s = s;
   actual.onSubscribe(s);
 }
コード例 #6
0
ファイル: FluxArray.java プロジェクト: bclozel/reactor-core
 @Override
 public void subscribe(Subscriber<? super T> s) {
   if (array.length == 0) {
     EmptySubscription.complete(s);
     return;
   }
   s.onSubscribe(new FluxArraySubscription<>(s, array));
 }
コード例 #7
0
    @Override
    public void onSubscribe(Subscription s) {
      if (SubscriptionHelper.validateSubscription(this.s, s)) {
        return;
      }
      this.s = s;

      Subscriber<? super U> actual = this.actual;

      U b;

      try {
        b = bufferSupplier.get();
      } catch (Throwable e) {
        cancelled = true;
        s.cancel();
        EmptySubscription.error(e, actual);
        return;
      }

      if (b == null) {
        cancelled = true;
        s.cancel();
        EmptySubscription.error(new NullPointerException("The buffer supplied is null"), actual);
        return;
      }
      buffer = b;

      Publisher<B> boundary;

      try {
        boundary = boundarySupplier.get();
      } catch (Throwable ex) {
        cancelled = true;
        s.cancel();
        EmptySubscription.error(ex, actual);
        return;
      }

      if (boundary == null) {
        cancelled = true;
        s.cancel();
        EmptySubscription.error(
            new NullPointerException("The boundary publisher supplied is null"), actual);
        return;
      }

      BufferBoundarySubscriber<T, U, B> bs = new BufferBoundarySubscriber<T, U, B>(this);
      other = bs;

      actual.onSubscribe(this);

      if (!cancelled) {
        s.request(Long.MAX_VALUE);

        boundary.subscribe(bs);
      }
    }
コード例 #8
0
    @Override
    public void onSubscribe(Subscription s) {
      if (Operators.validate(this.s, s)) {
        this.s = s;

        actual.onSubscribe(this);

        s.request(Long.MAX_VALUE);
      }
    }
コード例 #9
0
 @Override
 void subscribe(
     AbstractRequestBodyPublisher publisher, Subscriber<? super DataBuffer> subscriber) {
   Objects.requireNonNull(subscriber);
   if (publisher.changeState(this, NO_DEMAND)) {
     Subscription subscription = new RequestBodySubscription(publisher);
     publisher.subscriber = subscriber;
     subscriber.onSubscribe(subscription);
   } else {
     throw new IllegalStateException(toString());
   }
 }
コード例 #10
0
 @Override
 public void subscribe(final Subscriber<? super QueueSignal> subscriber) {
   try {
     if (refCount.getAndIncrement() == 0) {
       this.channel = lapin.createChannel();
     }
     subscriber.onSubscribe(createSubscription(subscriber, null, null));
   } catch (Exception e) {
     refCount.incrementAndGet();
     subscriber.onError(e);
   }
 }
コード例 #11
0
  /**
   * Common method to take an Iterator as a source of values.
   *
   * @param s
   * @param it
   */
  static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) {
    if (it == null) {
      EmptySubscription.error(s, new NullPointerException("The iterator is null"));
      return;
    }

    boolean b;

    try {
      b = it.hasNext();
    } catch (Throwable e) {
      EmptySubscription.error(s, e);
      return;
    }
    if (!b) {
      EmptySubscription.complete(s);
      return;
    }

    s.onSubscribe(new PublisherIterableSubscription<>(s, it));
  }
コード例 #12
0
 @Override
 public void onSubscribe(final Subscription s) {
   this.subscription = s;
   delegate.onSubscribe(this);
 }
コード例 #13
0
 @Override
 public void subscribe(Subscriber<? super Object> s) {
   s.onSubscribe(EmptySubscription.INSTANCE);
   s.onComplete();
 }
コード例 #14
0
ファイル: Publisher.java プロジェクト: vqvu/rx-stream-impl
 @Override
 public void subscribe(Subscriber<? super T> subscriber) {
   BasicSubcription<T> sub = new BasicSubcription<>(subscriber, createEmitter());
   subscriber.onSubscribe(sub);
 }
コード例 #15
0
ファイル: Processors.java プロジェクト: bripkens/reactor-core
 @Override
 public void onSubscribe(Subscription s) {
   upstream.onSubscribe(s);
 }