本文整理汇总了Java中java.util.concurrent.Flow.Publisher方法的典型用法代码示例。如果您正苦于以下问题:Java Flow.Publisher方法的具体用法?Java Flow.Publisher怎么用?Java Flow.Publisher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.Flow
的用法示例。
在下文中一共展示了Flow.Publisher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onError
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onError(Throwable throwable) {
if (once) {
actual.onError(throwable);
return;
}
once = true;
Flow.Publisher<? extends T> p;
try {
p = Objects.requireNonNull(handler.apply(throwable), "The handler returned a null Flow.Publisher");
} catch (Throwable ex) {
actual.onError(new CompositeThrowable(throwable, ex));
return;
}
long c = produced;
if (c != 0) {
arbiterProduced(c);
}
p.subscribe(this);
}
示例2: subscribeActual
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
protected void subscribeActual(FolyamSubscriber<? super R> s) {
Flow.Publisher<? extends R> p;
ConnectableFolyam<U> conn;
try {
conn = Objects.requireNonNull(multicaster.apply(source), "The multicaster returned a null ConnectableFolyam");
p = Objects.requireNonNull(handler.apply(conn), "The handler returned a null Flow.Publisher");
} catch (Throwable ex) {
EmptySubscription.error(s, ex);
return;
}
SequentialAutoDisposable sd = new SequentialAutoDisposable();
if (s instanceof ConditionalSubscriber) {
p.subscribe(new FolyamPublish.PublishConditionalSubscriber<>((ConditionalSubscriber<? super R>)s, sd));
} else {
p.subscribe(new FolyamPublish.PublishSubscriber<>(s, sd));
}
conn.connect(sd::replace);
}
示例3: createFlowPublisher
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public Flow.Publisher<List<Long>> createFlowPublisher(long elements) {
return
Folyam.fromIterable(iterate(elements))
.buffer(Folyam.just(1).concatWith(Folyam.<Integer>never()))
.onBackpressureLatest()
;
}
示例4: tryOnNext
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public boolean tryOnNext(T item) {
boolean b = false;
long idx = (long)INDEX.getAcquire(this);
if (idx != Long.MAX_VALUE && INDEX.compareAndSet(this, idx, idx + 1)) {
AutoDisposable d = task;
if (d != null && d != DisposableHelper.CLOSED) {
task = null;
b = !SubscriptionHelper.cancel((ItemSubscriber<?>)d);
}
Flow.Publisher<?> p;
try {
p = Objects.requireNonNull(itemDebouncer.apply(item), "The itemDebouncer returned a null Flow.Publisher");
} catch (Throwable ex) {
upstream.cancel();
onError(ex);
return false;
}
ItemSubscriber<T> inner = new ItemSubscriber<>(idx + 1, item, this);
if (DisposableHelper.replace(this, TASK, inner)) {
p.subscribe(inner);
}
}
return b;
}
示例5: createFlowPublisher
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public Flow.Publisher<Integer> createFlowPublisher(long elements) {
return
Folyam.range(0, (int)elements)
.flatMap(Folyam::just)
;
}
示例6: FolyamSwitchFlatMap
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public FolyamSwitchFlatMap(Folyam<T> source,
CheckedFunction<? super T, ? extends Flow.Publisher<? extends R>> mapper,
int maxActive, int bufferSize) {
super();
this.source = source;
this.mapper = mapper;
this.maxActive = maxActive;
this.bufferSize = bufferSize;
}
示例7: SwitchFlatMapSubscriber
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
SwitchFlatMapSubscriber(FolyamSubscriber<? super R> actual,
CheckedFunction<? super T, ? extends Flow.Publisher<? extends R>> mapper, int maxActive,
int bufferSize) {
this.actual = actual;
this.mapper = mapper;
this.maxActive = maxActive;
this.bufferSize = bufferSize;
this.active = new ArrayDeque<>();
this.activeCache = new SfmInnerSubscriber[maxActive];
}
示例8: createFlowPublisher
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Flow.Publisher<Long> createFlowPublisher(long elements) {
return
Folyam.combineLatest(Arrays.asList(
Folyam.just(1L),
Folyam.fromIterable(iterate(elements))
),
a -> (Long)a[0]
)
;
}
示例9: ConcatArraySubscriber
import java.util.concurrent.Flow; //导入方法依赖的package包/类
protected ConcatArraySubscriber(FolyamSubscriber<? super T> actual, Flow.Publisher<? extends T>[] sources, boolean delayError) {
super(sources, delayError);
this.actual = actual;
}
示例10: TimeoutTimedSelectorFallbackConditionalSubscriber
import java.util.concurrent.Flow; //导入方法依赖的package包/类
protected TimeoutTimedSelectorFallbackConditionalSubscriber(ConditionalSubscriber<? super T> actual, Flow.Publisher<?> firstTimeout, CheckedFunction<? super T, ? extends Flow.Publisher<?>> itemTimeoutSelector, Flow.Publisher<? extends T> fallback) {
super(firstTimeout, itemTimeoutSelector, fallback);
this.actual = actual;
}
示例11: createFlowPublisher
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public Flow.Publisher<Integer> createFlowPublisher(final long elements) {
return
Folyam.range(1, 1000).reduce((a, b) -> a + b).toFolyam()
;
}
示例12: FolyamCombineLatestIterable
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public FolyamCombineLatestIterable(Iterable<? extends Flow.Publisher<? extends T>> sources, CheckedFunction<? super Object[], ? extends R> combiner, int prefetch, boolean delayError) {
this.sources = sources;
this.combiner = combiner;
this.prefetch = prefetch;
this.delayError = delayError;
}
示例13: ReactivePublisherFromFlow
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public ReactivePublisherFromFlow(Flow.Publisher<? extends T> flowPublisher) {
this.flow = flowPublisher;
}
示例14: createFlowPublisher
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public Flow.Publisher<Integer> createFlowPublisher(long elements) {
return
Folyam.range(0, (int)elements * 2).skipLast((int)elements)
;
}
示例15: AbstractConcatIterable
import java.util.concurrent.Flow; //导入方法依赖的package包/类
AbstractConcatIterable(boolean delayError, Iterator<? extends Flow.Publisher<? extends T>> sources) {
this.delayError = delayError;
this.sources = sources;
}