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


Java Subscriber.onComplete方法代码示例

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


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

示例1: succeed

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
protected void succeed() {
    synchronized (this) {
        state = State.COMPLETING;
    }
    Subscriber<? super T> subscriber = subscriber();
    if (subscriber != null) {
        boolean complete = false;
        synchronized (this) {
            if (state == State.COMPLETING) {
                state = State.TERMINATED;
                complete = true;
            }
        }
        if (complete) {
            subscriber.onComplete();
        }
    }
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:19,代码来源:AbstractEventPublisher.java

示例2: fastPath

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
void fastPath() {
    T[] arr = array;
    int f = arr.length;
    Subscriber<? super T> a = actual;

    for (int i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        T t = arr[i];
        if (t == null) {
            a.onError(new NullPointerException("array element is null"));
            return;
        } else {
            a.onNext(t);
        }
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:24,代码来源:FlowableFromArray.java

示例3: fastPath

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
void fastPath() {
    int f = end;
    Subscriber<? super Integer> a = actual;

    for (int i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        a.onNext(i);
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:17,代码来源:FlowableRange.java

示例4: fastPath

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
void fastPath() {
    long f = end;
    Subscriber<? super Long> a = actual;

    for (long i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        a.onNext(i);
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:17,代码来源:FlowableRangeLong.java

示例5: doOnEmpty

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
public static <T> FlowableOperator<T, T> doOnEmpty(Action
                                                           action) {
    return new FlowableOperator<T, T>() {
        @Override
        public Subscriber<? super T> apply(Subscriber<? super
                T> subscriber) throws Exception {
            return new DisposableSubscriber<T>() {
                boolean isEmpty = true;

                @Override
                public void onNext(T value) {
                    isEmpty = false;
                    subscriber.onNext(value);
                }

                @Override
                public void onError(Throwable t) {
                    subscriber.onError(t);
                }

                @Override
                public void onComplete() {
                    if (isEmpty) {
                        try {
                            action.run();
                        } catch (Exception e) {
                            onError(e);
                            return;
                        }
                    }
                    subscriber.onComplete();
                }
            };
        }
    };
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:37,代码来源:Ch9_9.java

示例6: apply

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
public Subscriber<? super T> apply(final Subscriber<? super T> observer) {
    return new Subscriber<T>() {
        @Override
        public void onSubscribe(Subscription subscription) {
            if (subscribedOnce.getAndSet(true)) {
                throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
                        "concurrently. Use Flowable.share() instead.");
            } else {
                observer.onSubscribe(subscription);
            }
        }

        @Override
        public void onNext(T t) {
            observer.onNext(t);
        }

        @Override
        public void onError(Throwable throwable) {
            observer.onError(throwable);
        }

        @Override
        public void onComplete() {
            observer.onComplete();
        }
    };
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:30,代码来源:SubscribeOnlyOnceFlowableOperator.java

示例7: onRequest

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
protected void onRequest(long n) {
    if (!complete) {
        complete = true;
        Subscriber<? super ContentChunk> subscriber = subscriber();
        subscriber.onNext(new ContentChunk(ByteBuffer.wrap(bytes), Callback.NOOP));
        subscriber.onComplete();
    }
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:10,代码来源:StringContent.java

示例8: wrapSubscriber

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
    return new Subscriber<T>()
    {
        @Override
        public void onSubscribe(Subscription s) {
            subscriber.onSubscribe(s);
        }

        @Override
        public void onComplete()
        {
            subscriber.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            subscriber.onError(e);
        }

        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                subscriber.onNext(t);
        }
    };
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:30,代码来源:RxSubscriptionUtil.java

示例9: wrapSubscriber

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
    return new Subscriber<T>()
    {
        @Override
        public void onSubscribe(Subscription s) {
            subscriber.onSubscribe(s);
        }

        @Override
        public void onComplete()
        {
            subscriber.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            subscriber.onError(e);
        }


        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                subscriber.onNext(t);
        }
    };
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:31,代码来源:RxBusUtil.java

示例10: onNext

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
/**
 * Emits the given value if possible and terminates if there was an onComplete or onError
 * while emitting, drops the value otherwise.
 * @param <T> the value type
 * @param subscriber the target Subscriber to emit to
 * @param value the value to emit
 * @param wip the serialization work-in-progress counter/indicator
 * @param error the holder of Throwables
 */
public static <T> void onNext(Subscriber<? super T> subscriber, T value,
        AtomicInteger wip, AtomicThrowable error) {
    if (wip.get() == 0 && wip.compareAndSet(0, 1)) {
        subscriber.onNext(value);
        if (wip.decrementAndGet() != 0) {
            Throwable ex = error.terminate();
            if (ex != null) {
                subscriber.onError(ex);
            } else {
                subscriber.onComplete();
            }
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:24,代码来源:HalfSerializer.java

示例11: onComplete

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
/**
 * Emits an onComplete signal or an onError signal with the given error or indicates
 * the concurrently running onNext should do that.
 * @param subscriber the target Subscriber to emit to
 * @param wip the serialization work-in-progress counter/indicator
 * @param error the holder of Throwables
 */
public static void onComplete(Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable error) {
    if (wip.getAndIncrement() == 0) {
        Throwable ex = error.terminate();
        if (ex != null) {
            subscriber.onError(ex);
        } else {
            subscriber.onComplete();
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:18,代码来源:HalfSerializer.java

示例12: request

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
public void request(long n) {
    if (!SubscriptionHelper.validate(n)) {
        return;
    }
    if (compareAndSet(NO_REQUEST, REQUESTED)) {
        Subscriber<? super T> s = subscriber;

        s.onNext(value);
        if (get() != CANCELLED) {
            s.onComplete();
        }
    }

}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:16,代码来源:ScalarSubscription.java

示例13: request

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
public final void request(long n) {
    if (SubscriptionHelper.validate(n)) {
        for (;;) {
            int state = get();
            // if the any bits 1-31 are set, we are either in fusion mode (FUSED_*)
            // or request has been called (HAS_REQUEST_*)
            if ((state & ~NO_REQUEST_HAS_VALUE) != 0) {
                return;
            }
            if (state == NO_REQUEST_HAS_VALUE) {
                if (compareAndSet(NO_REQUEST_HAS_VALUE, HAS_REQUEST_HAS_VALUE)) {
                    T v = value;
                    if (v != null) {
                        value = null;
                        Subscriber<? super T> a = actual;
                        a.onNext(v);
                        if (get() != CANCELLED) {
                            a.onComplete();
                        }
                    }
                }
                return;
            }
            if (compareAndSet(NO_REQUEST_NO_VALUE, HAS_REQUEST_NO_VALUE)) {
                return;
            }
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:31,代码来源:DeferredScalarSubscription.java

示例14: slowPath

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
void slowPath(long r) {
    long e = 0;
    int f = end;
    int i = index;
    Subscriber<? super Integer> a = actual;

    for (;;) {

        while (e != r && i != f) {
            if (cancelled) {
                return;
            }

            a.onNext(i);

            e++;
            i++;
        }

        if (i == f) {
            if (!cancelled) {
                a.onComplete();
            }
            return;
        }

        r = get();
        if (e == r) {
            index = i;
            r = addAndGet(-e);
            if (r == 0L) {
                return;
            }
            e = 0L;
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:39,代码来源:FlowableRange.java

示例15: slowPath

import org.reactivestreams.Subscriber; //导入方法依赖的package包/类
@Override
void slowPath(long r) {
    long e = 0;
    long f = end;
    long i = index;
    Subscriber<? super Long> a = actual;

    for (;;) {

        while (e != r && i != f) {
            if (cancelled) {
                return;
            }

            a.onNext(i);

            e++;
            i++;
        }

        if (i == f) {
            if (!cancelled) {
                a.onComplete();
            }
            return;
        }

        r = get();
        if (e == r) {
            index = i;
            r = addAndGet(-e);
            if (r == 0L) {
                return;
            }
            e = 0L;
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:39,代码来源:FlowableRangeLong.java


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