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


Java Flow.Subscription方法代码示例

本文整理汇总了Java中java.util.concurrent.Flow.Subscription方法的典型用法代码示例。如果您正苦于以下问题:Java Flow.Subscription方法的具体用法?Java Flow.Subscription怎么用?Java Flow.Subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.Flow的用法示例。


在下文中一共展示了Flow.Subscription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public final void onSubscribe(Flow.Subscription subscription) {
    upstream = subscription;
    if (subscription instanceof FusedSubscription) {
        FusedSubscription<T> fs = (FusedSubscription<T>) subscription;
        int m = fs.requestFusion(ANY);
        if (m == SYNC) {
            sourceFused = m;
            queue = fs;
            DONE.setRelease(this, true);
            onStart();
            return;
        }
        if (m == ASYNC) {
            sourceFused = m;
            queue = fs;
            onStart();
            fs.request(prefetch);
            return;
        }
    }

    int pf = prefetch;
    if (pf == 1) {
        queue = new SpscOneQueue<>();
    } else {
        queue = new SpscArrayQueue<>(pf);
    }

    onStart();

    subscription.request(pf);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:34,代码来源:FolyamFlattenIterable.java

示例2: replaceRace

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void replaceRace() {
    for (int i = 0; i < 1000; i++) {
        AtomicReference<Flow.Subscription> ref = new AtomicReference<>();

        BooleanSubscription d1 = new BooleanSubscription();
        BooleanSubscription d2 = new BooleanSubscription();

        Runnable r1 = () -> SubscriptionHelper.replace(ref, d1);
        Runnable r2 = () -> SubscriptionHelper.replace(ref, d2);

        TestHelper.race(r1, r2);
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:15,代码来源:SubscriptionHelperTest.java

示例3: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    upstream = subscription;
    if (subscription instanceof FusedSubscription) {
        FusedSubscription fs = (FusedSubscription) subscription;

        int m = fs.requestFusion(FusedSubscription.ANY);
        if (m == FusedSubscription.SYNC) {
            fusionMode = m;
            queue = fs;
            DONE.setRelease(this, true);

            actual.onSubscribe(this);

            drain();
            return;
        }
        if (m == FusedSubscription.ASYNC) {
            fusionMode = m;
            queue = fs;

            actual.onSubscribe(this);

            subscription.request(prefetch);
            return;
        }
    }

    queue = new SpscArrayQueue<>(prefetch);

    actual.onSubscribe(this);

    subscription.request(prefetch);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:35,代码来源:FolyamConcatMap.java

示例4: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    if (SUBSCRIBERS.getAcquire(this) == TERMINATED) {
        subscription.cancel();
    } else {
        subscription.request(Long.MAX_VALUE);
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:9,代码来源:DirectProcessor.java

示例5: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public final void onSubscribe(Flow.Subscription subscription) {
    upstream = subscription;
    onStart();
    int mc = maxConcurrency;
    if (mc == Integer.MAX_VALUE) {
        subscription.request(Long.MAX_VALUE);
    } else {
        subscription.request(mc);
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:12,代码来源:FolyamConcatMapEager.java

示例6: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription s) {
    if (remaining == 0L) {
        s.cancel();
        EmptySubscription.complete(actual);
    } else {
        this.upstream = s;
        actual.onSubscribe(this);
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:11,代码来源:FolyamLimit.java

示例7: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    if (this.subscription != null) {
        throw new IllegalStateException();
    }
    this.subscription = subscription;
    subscription.request(1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:Stream.java

示例8: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public void onSubscribe(Flow.Subscription subscription) {
    arbiterReplace(subscription);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:4,代码来源:FolyamConcatIterable.java

示例9: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    arbiterReplace(subscription);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:5,代码来源:FolyamSwitchIfEmptyMany.java

示例10: IteratorCleanup

import java.util.concurrent.Flow; //导入方法依赖的package包/类
IteratorCleanup(Flow.Subscription upstream) {
    this.upstream = upstream;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:4,代码来源:FolyamBlockingIterable.java

示例11: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    upstream = subscription;
    actual.onSubscribe(this);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:6,代码来源:EsetlegHide.java

示例12: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    if (SubscriptionHelper.replace(this, subscription)) {
        subscription.request(Long.MAX_VALUE);
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:ParallelSumInt.java

示例13: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription s) {
    this.s = s;

    actual.onSubscribe(this);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:ParallelMapTry.java

示例14: LambdaConsumer

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public LambdaConsumer(CheckedConsumer<? super T> onNext, CheckedConsumer<? super Throwable> onError, CheckedRunnable onComplete, CheckedConsumer<? super Flow.Subscription> onSubscribe) {
    this.onNext = onNext;
    this.onError = onError;
    this.onComplete = onComplete;
    this.onSubscribe = onSubscribe;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:7,代码来源:LambdaConsumer.java

示例15: onSubscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void onSubscribe(Flow.Subscription subscription) {
    subscribeMain(subscription);
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:5,代码来源:FolyamDelaySubscription.java


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