Search in sources :

Example 1 with ParallelFlowable

use of io.reactivex.parallel.ParallelFlowable in project RxJavaInAction by fengzhizi715.

the class ParallelFlowableForParallel method main.

public static void main(String[] args) {
    ParallelFlowable parallelFlowable = Flowable.range(1, 100).parallel();
    parallelFlowable.runOn(Schedulers.io()).map(new Function<Integer, Object>() {

        @Override
        public Object apply(@NonNull Integer integer) throws Exception {
            return integer.toString();
        }
    }).sequential().subscribe(new Consumer<String>() {

        @Override
        public void accept(@NonNull String str) throws Exception {
            System.out.println(str);
        }
    });
}
Also used : ParallelFlowable(io.reactivex.parallel.ParallelFlowable)

Example 2 with ParallelFlowable

use of io.reactivex.parallel.ParallelFlowable in project brave by openzipkin.

the class CurrentTraceContextAssemblyTrackingMatrixTest method subscribeInDifferentContext.

TestObserver<Integer> subscribeInDifferentContext(ParallelFlowable<Integer> source, ParallelFlowable<Integer> errorSource) {
    source = source.doOnSubscribe(s -> assertInSubscribeContext());
    errorSource = errorSource.doOnSubscribe(s -> assertInSubscribeContext());
    try (Scope scope2 = currentTraceContext.newScope(subscribeContext)) {
        errorSource.sequential().test().assertFailure(IllegalStateException.class);
        return source.sequential().toObservable().test();
    }
}
Also used : MaybeObserver(io.reactivex.MaybeObserver) ScalarCallable(io.reactivex.internal.fuseable.ScalarCallable) ObservableRange(io.reactivex.internal.operators.observable.ObservableRange) ParallelFilter(io.reactivex.internal.operators.parallel.ParallelFilter) FlowableFromCallable(io.reactivex.internal.operators.flowable.FlowableFromCallable) Completable(io.reactivex.Completable) FlowableFilter(io.reactivex.internal.operators.flowable.FlowableFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Maybe(io.reactivex.Maybe) ConnectableFlowable(io.reactivex.flowables.ConnectableFlowable) StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) Callable(java.util.concurrent.Callable) CurrentTraceContext(brave.propagation.CurrentTraceContext) SingleFromCallable(io.reactivex.internal.operators.single.SingleFromCallable) Single(io.reactivex.Single) SingleJust(io.reactivex.internal.operators.single.SingleJust) MaybeFromCallable(io.reactivex.internal.operators.maybe.MaybeFromCallable) ParallelFlowable(io.reactivex.parallel.ParallelFlowable) Flowable(io.reactivex.Flowable) CompletableFromCallable(io.reactivex.internal.operators.completable.CompletableFromCallable) After(org.junit.After) Observable(io.reactivex.Observable) Subscriber(org.reactivestreams.Subscriber) MaybeFilterSingle(io.reactivex.internal.operators.maybe.MaybeFilterSingle) Before(org.junit.Before) ObservablePublish(io.reactivex.internal.operators.observable.ObservablePublish) ConnectableObservable(io.reactivex.observables.ConnectableObservable) CompletableObserver(io.reactivex.CompletableObserver) ParallelFromPublisher(io.reactivex.internal.operators.parallel.ParallelFromPublisher) CompletableEmpty(io.reactivex.internal.operators.completable.CompletableEmpty) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) RxJavaPlugins(io.reactivex.plugins.RxJavaPlugins) Predicate(io.reactivex.functions.Predicate) TraceContext(brave.propagation.TraceContext) MaybeFilter(io.reactivex.internal.operators.maybe.MaybeFilter) FlowablePublish(io.reactivex.internal.operators.flowable.FlowablePublish) ObservableFromCallable(io.reactivex.internal.operators.observable.ObservableFromCallable) SingleObserver(io.reactivex.SingleObserver) FlowableRange(io.reactivex.internal.operators.flowable.FlowableRange) MaybeJust(io.reactivex.internal.operators.maybe.MaybeJust) Observer(io.reactivex.Observer) Scope(brave.propagation.CurrentTraceContext.Scope) ObservableFilter(io.reactivex.internal.operators.observable.ObservableFilter) Scope(brave.propagation.CurrentTraceContext.Scope)

Aggregations

ParallelFlowable (io.reactivex.parallel.ParallelFlowable)2 CurrentTraceContext (brave.propagation.CurrentTraceContext)1 Scope (brave.propagation.CurrentTraceContext.Scope)1 StrictCurrentTraceContext (brave.propagation.StrictCurrentTraceContext)1 TraceContext (brave.propagation.TraceContext)1 Completable (io.reactivex.Completable)1 CompletableObserver (io.reactivex.CompletableObserver)1 Flowable (io.reactivex.Flowable)1 Maybe (io.reactivex.Maybe)1 MaybeObserver (io.reactivex.MaybeObserver)1 Observable (io.reactivex.Observable)1 Observer (io.reactivex.Observer)1 Single (io.reactivex.Single)1 SingleObserver (io.reactivex.SingleObserver)1 ConnectableFlowable (io.reactivex.flowables.ConnectableFlowable)1 Predicate (io.reactivex.functions.Predicate)1 ScalarCallable (io.reactivex.internal.fuseable.ScalarCallable)1 CompletableEmpty (io.reactivex.internal.operators.completable.CompletableEmpty)1 CompletableFromCallable (io.reactivex.internal.operators.completable.CompletableFromCallable)1 FlowableFilter (io.reactivex.internal.operators.flowable.FlowableFilter)1