Java Code Examples for rx.schedulers.Schedulers#newThread()

The following examples show how to use rx.schedulers.Schedulers#newThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulersLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenScheduledWorker_whenUnsubscribeOnWorker_thenResultFirstAction() throws InterruptedException {
    System.out.println("canceling");
    Scheduler scheduler = Schedulers.newThread();
    Scheduler.Worker worker = scheduler.createWorker();
    worker.schedule(() -> {
        result += "First_Action";
        worker.unsubscribe();
    });
    worker.schedule(() -> result += "Second_Action");

    await()
      .until(() -> assertTrue(result.equals("First_Action")));
}
 
Example 2
Source File: SchedulersLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Ignore //it's not safe, not every time is running correctly
@Test
public void givenWorker_whenScheduledOnNewThread_thenResultIsBoundToNewThread() throws InterruptedException {
    System.out.println("newThread_1");
    Scheduler scheduler = Schedulers.newThread();
    Scheduler.Worker worker = scheduler.createWorker();
    worker.schedule(() -> {
        result += Thread.currentThread().getName() + "_Start";
        worker.schedule(() -> result += "_worker_");
        result += "_End";
    });

    await()
      .until(() -> assertTrue(result.equals("RxNewThreadScheduler-1_Start_End_worker_")));
}
 
Example 3
Source File: AndroidAppThreads.java    From DebugRank with Apache License 2.0 4 votes vote down vote up
@Override
public Scheduler newThread()
{
    return Schedulers.newThread();
}
 
Example 4
Source File: AppModule.java    From Game-of-Thrones with Apache License 2.0 4 votes vote down vote up
@Provides
@ExecutorThread
public Scheduler provideMainThread() {
  return Schedulers.newThread();
}