com.gs.api.accelrx.context.rxjava3.ContextPropagatorOnFlowableAssemblyAction Maven / Gradle / Ivy
The newest version!
package com.gs.api.accelrx.context.rxjava3;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.functions.Function;
import org.reactivestreams.Subscriber;
import java.util.concurrent.Executor;
@SuppressWarnings("rawtypes")
public class ContextPropagatorOnFlowableAssemblyAction implements Function {
private final ThreadContext threadContext;
public ContextPropagatorOnFlowableAssemblyAction(ThreadContext threadContext) {
this.threadContext = threadContext;
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Flowable apply(Flowable flowable) throws Throwable {
return new ContextPropagatorFlowable<>(flowable, threadContext.currentContextExecutor());
}
private static final class ContextPropagatorFlowable extends Flowable {
private final Flowable source;
private final Executor contextExecutor;
public ContextPropagatorFlowable(Flowable single, Executor contextExecutor) {
this.source = single;
this.contextExecutor = contextExecutor;
}
@Override
protected void subscribeActual(@NonNull Subscriber super T> subscriber) {
contextExecutor.execute(() -> source.subscribe(subscriber));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy