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


Java RxJavaHooks.setOnScheduleAction方法代码示例

本文整理汇总了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();
        }
    });
}
 
开发者ID:sumio,项目名称:RxJavaEspressoSample,代码行数:11,代码来源:ActivityCountingIdlingResourceTest.java

示例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();
          }
        }
      };
    }
  });
}
 
开发者ID:opentracing-contrib,项目名称:java-rxjava,代码行数:59,代码来源:TracingRxJavaUtils.java

示例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);
}
 
开发者ID:bmcstdio,项目名称:rxjava-slf4j-mdc-hook,代码行数:5,代码来源:MdcPropagatingOnScheduleActionTests.java

示例6: beforeClass

import rx.plugins.RxJavaHooks; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  RxJavaHooks.setOnScheduleAction(new MdcPropagatingOnScheduleAction());
}
 
开发者ID:bmcstdio,项目名称:rxjava-slf4j-mdc-hook,代码行数:5,代码来源:MdcPropagatingOnScheduleActionTests.java


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