本文整理汇总了Java中rx.plugins.RxJavaHooks.setOnScheduleAction方法的典型用法代码示例。如果您正苦于以下问题:Java RxJavaHooks.setOnScheduleAction方法的具体用法?Java RxJavaHooks.setOnScheduleAction怎么用?Java RxJavaHooks.setOnScheduleAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.plugins.RxJavaHooks
的用法示例。
在下文中一共展示了RxJavaHooks.setOnScheduleAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decorateScheduledActionWithIdlingResource
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
RxJavaHooks.setOnScheduleAction(oldAction -> () -> {
try {
countingIdlingResource.increment();
oldAction.call();
} finally {
countingIdlingResource.decrement();
}
});
}
示例2: enableTracing
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void enableTracing(final Tracer tracer) {
RxJavaHooks.setOnScheduleAction(new Func1<Action0, Action0>() {
@Override
public Action0 call(final Action0 action0) {
return new TracingAction(action0, tracer);
}
});
RxJavaHooks.setOnObservableStart(new Func2<Observable, OnSubscribe, OnSubscribe>() {
@Override
public OnSubscribe call(final Observable observable, final OnSubscribe onSubscribe) {
return new OnSubscribe<Subscriber>() {
@Override
public void call(Subscriber subscriber) {
Scope scope = null;
if (subscriber instanceof SafeSubscriber) {
SafeSubscriber safeSubscriber = (SafeSubscriber) subscriber;
Subscriber subscriber2 = safeSubscriber.getActual();
if (subscriber2 instanceof AbstractTracingSubscriber) {
AbstractTracingSubscriber tracingSubscriber = (AbstractTracingSubscriber) subscriber2;
Span span = tracingSubscriber.getSpan();
scope = tracer.scopeManager().activate(span, false);
} /* else if (tracer.scopeManager().active() != null) {
// if there is no parent don't create new span
final Scope scope2 = tracer.buildSpan("observable")
.startActive(Observer.FINISH_ON_CLOSE);
subscriber2.add(new Subscription() {
private volatile boolean unsubscribed;
@Override
public void unsubscribe() {
scope2.close();
unsubscribed = true;
}
@Override
public boolean isUnsubscribed() {
return unsubscribed;
}
});
}*/
}
onSubscribe.call(subscriber);
if (scope != null) {
scope.close();
}
}
};
}
});
}
示例3: afterClass
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@AfterClass
public static void afterClass() {
RxJavaHooks.setOnScheduleAction(null);
}
开发者ID:bmcstdio,项目名称:rxjava-grpc-context-hook,代码行数:5,代码来源:GrpcContextPropagatingOnScheduleActionTests.java
示例4: beforeClass
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
RxJavaHooks.setOnScheduleAction(new GrpcContextPropagatingOnScheduleAction());
}
开发者ID:bmcstdio,项目名称:rxjava-grpc-context-hook,代码行数:5,代码来源:GrpcContextPropagatingOnScheduleActionTests.java
示例5: afterClass
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@AfterClass
public static void afterClass() throws Exception {
RxJavaHooks.setOnScheduleAction(null);
}
示例6: beforeClass
import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
RxJavaHooks.setOnScheduleAction(new MdcPropagatingOnScheduleAction());
}