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


Java Schedulers.from方法代码示例

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


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

示例1: demo2

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
private static void demo2() throws Exception {
    final ExecutorService executor = Executors.newFixedThreadPool(1000);
    final Scheduler pooledScheduler = Schedulers.from(executor);

    Observable.range(1, 10000)
            .flatMap(i -> Observable.just(i)
                    .subscribeOn(pooledScheduler)
                    .map(Sandbox::importantLongTask)
            )
            .doOnTerminate(WAIT_LATCH::countDown)
            .map(Object::toString)
            .subscribe(e -> log("subscribe", e));

    WAIT_LATCH.await();
    executor.shutdown();
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:17,代码来源:Sandbox.java

示例2: demo2

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
private static void demo2() throws Exception {
    final ExecutorService executor = Executors.newFixedThreadPool(1000);
    final Scheduler pooledScheduler = Schedulers.from(executor);

    Observable.range(1, 10000)
            .flatMap(i -> Observable.just(i)
                    .subscribeOn(pooledScheduler)
                    .map(Sandbox::importantLongTask)
            )
            .doOnTerminate(WAIT_LATCH::countDown)
            .map(Objects::toString)
            .subscribe(e -> log("subscribe", e));

    WAIT_LATCH.await();
    executor.shutdown();
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:17,代码来源:Sandbox.java

示例3: setUp

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    permissionSubject = PublishSubject.create();
    locationSubject = PublishSubject.create();
    pageChanged = PublishSubject.create();

    doReturn(permissionSubject).when(pm).onPermissionGranted();
    doReturn(locationSubject).when(locationService).onNewLocation();
    doReturn(true).when(locationService).isGpsProviderEnabled();
    doReturn(Observable.empty()).when(weatherService).getTomorrowWeather(anyDouble(), anyDouble());

    final Scheduler androidScheduler = Schedulers.from(new CurrentThreadExecutor());
    vm = new TomorrowWeatherViewModel(navigation, pageChanged, pm,
            locationService, weatherService, weatherParser, androidScheduler);
    vm.state = new WeatherViewModel.WeatherViewModelState();
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:19,代码来源:TestTomorrowWeatherViewModel.java

示例4: setUp

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    permissionSubject = PublishSubject.create();
    locationSubject = PublishSubject.create();
    pageChanged = PublishSubject.create();

    doReturn(permissionSubject).when(pm).onPermissionGranted();
    doReturn(locationSubject).when(locationService).onNewLocation();
    doReturn(true).when(locationService).isGpsProviderEnabled();
    doReturn(Observable.empty()).when(weatherService).getCurrentWeather(anyDouble(), anyDouble());

    final Scheduler androidScheduler = Schedulers.from(new CurrentThreadExecutor());
    vm = new TodayWeatherViewModel(navigation, pageChanged, pm, locationService, weatherService, weatherParser, androidScheduler);
    vm.state = new WeatherViewModel.WeatherViewModelState();
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:18,代码来源:TestTodayWeatherViewModel.java

示例5: main

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
public static void main(String[] args) {
    int numberOfThreads = 20;
    ExecutorService executor =
            Executors.newFixedThreadPool(numberOfThreads);
    Scheduler scheduler = Schedulers.from(executor);
    Observable.just("Alpha", "Beta", "Gamma", "Delta",
            "Epsilon")
            .subscribeOn(scheduler)
            .doFinally(executor::shutdown)
            .subscribe(System.out::println);
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:12,代码来源:Ch6_7.java

示例6: onCreate

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    this.messagesInteractor = InteractorFactory.createMessagesInteractor();
    this.mSenderScheduler = Schedulers.from(Executors.newFixedThreadPool(1));
    this.registeredAccounts = Settings.get().accounts().getRegistered();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:8,代码来源:SendService.java

示例7: autoClose

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
public static Scheduler autoClose(ExecutorService pool) {
  Scheduler scheduler = Schedulers.from(pool);
  FinalizeSupport.finalize(scheduler, () -> {
    debug().log("Shutdown the scheduler from: " + pool);
    pool.shutdown();
  });
  return scheduler;
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:9,代码来源:RxSchedulers.java

示例8: initExtractScheduler

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
/**
 * Initializes a scheduler that will be used for offloading IO work performed by {@link Extract}s
 * <p/>
 * <p/> Threads executed on this scheduler have {@link Thread#NORM_PRIORITY}
 * @param ioPoolSize Size of thread pool for this scheduler
 */
private Scheduler initExtractScheduler(Integer ioPoolSize) {
    ThreadFactory factory = newThreadFactory("TaskManager-Extract-%s", Thread.NORM_PRIORITY);
    ExecutorService executor = Executors.newFixedThreadPool(ioPoolSize, factory);
    shutdownHook.registerExecutor(executor);
    return Schedulers.from(executor);
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:13,代码来源:TaskManager.java

示例9: initTransformScheduler

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
/**
 * Initializes a scheduler that will be used for offloading IO work performed by {@link PollingTransform}s
 * <p/>
 * <p/> Threads executed on this scheduler have {@link Thread#NORM_PRIORITY+1}
 * @param ioPoolSize Size of thread pool for this scheduler
 */
private Scheduler initTransformScheduler(Integer ioPoolSize) {
    ThreadFactory factory = newThreadFactory("TaskManager-Transform-%s", Thread.NORM_PRIORITY + 1);
    ExecutorService executor = Executors.newFixedThreadPool(ioPoolSize, factory);
    shutdownHook.registerExecutor(executor);
    return Schedulers.from(executor);
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:13,代码来源:TaskManager.java

示例10: initLoadScheduler

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
/**
 * Initializes a scheduler that will be used for offloading IO work performed by {@link Load}s
 * <p/>
 * <p/> Threads executed on this scheduler have {@link Thread#NORM_PRIORITY}+2
 * @param ioPoolSize Size of thread pool for this scheduler
 */
private Scheduler initLoadScheduler(Integer ioPoolSize) {
    ThreadFactory factory = newThreadFactory("TaskManager-Load-%s", Thread.NORM_PRIORITY + 2);
    ExecutorService executor = Executors.newFixedThreadPool(ioPoolSize, factory);
    shutdownHook.registerExecutor(executor);
    return Schedulers.from(executor);
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:13,代码来源:TaskManager.java

示例11: setUp

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    item = fakeResponse(Responses.JSON.SEARCH);
    doReturn(Observable.just(item))
            .when(weatherApi).searchWeather(anyString());
    searchService = new SearchService(weatherApi, Schedulers.from(new CurrentThreadExecutor()));
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:8,代码来源:TestSearchService.java

示例12: demo3

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
private static void demo3() {
    final ExecutorService executor = Executors.newFixedThreadPool(10);
    final Scheduler pooledScheduler = Schedulers.from(executor);

    Observable.range(1, 100)
            .subscribeOn(pooledScheduler)
            .map(Objects::toString)
            .subscribe(e -> log("subscribe", e));
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Android-Programming,代码行数:10,代码来源:Sandbox.java

示例13: ExecutorBackedScheduler

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
protected ExecutorBackedScheduler(ExecController execController) {
  this.execController = execController;
  this.delegateScheduler = Schedulers.from(getExecutor());
}
 
开发者ID:drmaas,项目名称:ratpack-rx2,代码行数:5,代码来源:ExecutorBackedScheduler.java

示例14: localPoolConfiguration

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
@Bean
@Conditional(NoTestSchedulerPresent.class)
public PoolConfiguration localPoolConfiguration() {
    return new PoolConfiguration(Schedulers.from(Executors.newFixedThreadPool(threadPoolSize)), observeOnCapacity);
}
 
开发者ID:streamingpool,项目名称:streamingpool-core,代码行数:6,代码来源:DefaultPoolConfiguration.java

示例15: prepareDiscoveryService

import io.reactivex.schedulers.Schedulers; //导入方法依赖的package包/类
private DiscoveryService prepareDiscoveryService(final List<StreamFactory> factories) {
    return new LocalPool(factories, new PoolConfiguration(Schedulers.from(Executors.newSingleThreadExecutor())));
}
 
开发者ID:streamingpool,项目名称:streamingpool-core,代码行数:4,代码来源:DiscoveryTest.java


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