reactor.core.publisher.Operators.replace()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中reactor.core.publisher.Operators.replace()方法的一些代码示例,展示了Operators.replace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operators.replace()方法的具体详情如下:
包路径:reactor.core.publisher.Operators
类名称:Operators
方法名:replace

Operators.replace介绍

[英]A generic utility to atomically replace a subscription or cancel the replacement if the current subscription is marked as already cancelled (as in #cancelledSubscription()).
[中]一个通用实用程序,用于自动替换订阅或在当前订阅被标记为已取消时取消替换(如#cancelled subscription()中)。

代码示例

代码示例来源:origin: reactor/reactor-core

@Override
public void onSubscribe(Subscription s) {
  if (Operators.replace(S, this, s)) {
    s.request(Long.MAX_VALUE);
  }
}

代码示例来源:origin: reactor/reactor-core

@Override
public void onNext(T t) {
  long idx = INDEX.incrementAndGet(this);
  if (!Operators.set(OTHER, this, Operators.emptySubscription())) {
    return;
  }
  Publisher<U> p;
  try {
    p = Objects.requireNonNull(throttler.apply(t),
        "throttler returned a null publisher");
  }
  catch (Throwable e) {
    onError(Operators.onOperatorError(s, e, t, ctx));
    return;
  }
  SampleTimeoutOther<T, U> os = new SampleTimeoutOther<>(this, t, idx);
  if (Operators.replace(OTHER, this, os)) {
    p.subscribe(os);
  }
}

代码示例来源:origin: reactor/reactor-core

if (Operators.replace(OTHER, this, other)) {
  p.subscribe(other);

代码示例来源:origin: io.projectreactor/reactor-core

@Override
public void onSubscribe(Subscription s) {
  if (Operators.replace(S, this, s)) {
    s.request(Long.MAX_VALUE);
  }
}

代码示例来源:origin: io.projectreactor/reactor-core

@Override
public void onNext(T t) {
  long idx = INDEX.incrementAndGet(this);
  if (!Operators.set(OTHER, this, Operators.emptySubscription())) {
    return;
  }
  Publisher<U> p;
  try {
    p = Objects.requireNonNull(throttler.apply(t),
        "throttler returned a null publisher");
  }
  catch (Throwable e) {
    onError(Operators.onOperatorError(s, e, t, ctx));
    return;
  }
  SampleTimeoutOther<T, U> os = new SampleTimeoutOther<>(this, t, idx);
  if (Operators.replace(OTHER, this, os)) {
    p.subscribe(os);
  }
}

代码示例来源:origin: io.projectreactor/reactor-core

if (Operators.replace(OTHER, this, other)) {
  p.subscribe(other);

相关文章