当前位置: 首页>>代码示例>>Java>>正文


Java Flow.Publisher方法代码示例

本文整理汇总了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);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:23,代码来源:FolyamOnErrorResumeNext.java

示例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);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:23,代码来源:FolyamMulticast.java

示例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()
    ;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:9,代码来源:BufferBoundaryTckTest.java

示例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;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:32,代码来源:FolyamDebounce.java

示例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)
        ;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:8,代码来源:FlatMapTckTest.java

示例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;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:10,代码来源:FolyamSwitchFlatMap.java

示例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];
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:12,代码来源:FolyamSwitchFlatMap.java

示例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]
        )
    ;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:13,代码来源:CombineLatestIterableTckTest.java

示例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;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:5,代码来源:FolyamConcatArray.java

示例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;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:5,代码来源:FolyamTimeoutSelectorFallback.java

示例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()
        ;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:ReduceTckTest.java

示例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;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:FolyamCombineLatestIterable.java

示例13: ReactivePublisherFromFlow

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public ReactivePublisherFromFlow(Flow.Publisher<? extends T> flowPublisher) {
    this.flow = flowPublisher;
}
 
开发者ID:OlegDokuka,项目名称:reactive-streams-tck_playground,代码行数:4,代码来源:ReactiveStreamsFlowBridge.java

示例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)
    ;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:SkipLastTckTest.java

示例15: AbstractConcatIterable

import java.util.concurrent.Flow; //导入方法依赖的package包/类
AbstractConcatIterable(boolean delayError, Iterator<? extends Flow.Publisher<? extends T>> sources) {
    this.delayError = delayError;
    this.sources = sources;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:5,代码来源:FolyamConcatIterable.java


注:本文中的java.util.concurrent.Flow.Publisher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。