Skip to content

Commit

Permalink
Scheduler.Inner -> Scheduler.Worker
Browse files Browse the repository at this point in the history
As per decision at ReactiveX#997 (comment)
  • Loading branch information
benjchristensen committed Apr 23, 2014
1 parent ed26962 commit 598afbb
Show file tree
Hide file tree
Showing 52 changed files with 158 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ object JavaConversions {
implicit def scalaSchedulerToJavaScheduler(s: Scheduler): rx.Scheduler = s.asJavaScheduler
implicit def javaSchedulerToScalaScheduler(s: rx.Scheduler): Scheduler = Scheduler(s)

implicit def scalaInnerToJavaInner(s: Inner): rx.Scheduler.Inner = s.asJavaInner
implicit def javaInnerToScalaInner(s: rx.Scheduler.Inner): Inner = Inner(s)
implicit def scalaWorkerToJavaWorker(s: Worker): rx.Scheduler.Worker = s.asJavaWorker
implicit def javaWorkerToScalaWorker(s: rx.Scheduler.Worker): Worker = Worker(s)


implicit def toJavaObserver[T](s: Observer[T]): rx.Observer[_ >: T] = s.asJavaObserver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ trait Scheduler {
*/
def now: Long = this.asJavaScheduler.now()

def createInner: Inner = this.asJavaScheduler.createInner()
def createWorker: Worker = this.asJavaScheduler.createWorker()

}

object Inner {
def apply(inner: rx.Scheduler.Inner): Inner = new Inner { private[scala] val asJavaInner = inner }
object Worker {
def apply(worker: rx.Scheduler.Worker): Worker = new Worker { private[scala] val asJavaWorker = worker }
}

trait Inner extends Subscription {
private [scala] val asJavaInner: rx.Scheduler.Inner
trait Worker extends Subscription {
private [scala] val asJavaWorker: rx.Scheduler.Worker

/**
* Schedules a cancelable action to be executed in delayTime.
*/
def schedule(action: Unit => Unit, delayTime: Duration): Subscription =
this.asJavaInner.schedule(
this.asJavaWorker.schedule(
new Action0 {
override def call(): Unit = action()
},
Expand All @@ -67,7 +67,7 @@ trait Inner extends Subscription {
/**
* Schedules a cancelable action to be executed immediately.
*/
def schedule(action: Unit => Unit): Subscription = this.asJavaInner.schedule(
def schedule(action: Unit => Unit): Subscription = this.asJavaWorker.schedule(
new Action0 {
override def call(): Unit = action()
}
Expand All @@ -76,7 +76,7 @@ trait Inner extends Subscription {
/**
* @return the scheduler's notion of current absolute time in milliseconds.
*/
def now: Long = this.asJavaInner.now()
def now: Long = this.asJavaWorker.now()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public HandlerThreadScheduler(Handler handler) {
}

@Override
public Inner createInner() {
public Worker createWorker() {
return new InnerHandlerThreadScheduler(handler);
}

private static class InnerHandlerThreadScheduler extends Inner {
private static class InnerHandlerThreadScheduler extends Worker {

private final Handler handler;
private BooleanSubscription innerSubscription = new BooleanSubscription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package rx.android.subscriptions;

import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action0;
Expand All @@ -42,7 +42,7 @@ public void call() {
if (Looper.getMainLooper() == Looper.myLooper()) {
unsubscribe.call();
} else {
final Inner inner = AndroidSchedulers.mainThread().createInner();
final Worker inner = AndroidSchedulers.mainThread().createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.robolectric.annotation.Config;

import rx.Scheduler;
import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.functions.Action0;
import rx.functions.Action1;
import android.os.Handler;
Expand All @@ -45,7 +45,7 @@ public void shouldScheduleImmediateActionOnHandlerThread() {
final Action0 action = mock(Action0.class);

Scheduler scheduler = new HandlerThreadScheduler(handler);
Inner inner = scheduler.createInner();
Worker inner = scheduler.createWorker();
inner.schedule(action);

// verify that we post to the given Handler
Expand All @@ -64,7 +64,7 @@ public void shouldScheduleDelayedActionOnHandlerThread() {
final Action0 action = mock(Action0.class);

Scheduler scheduler = new HandlerThreadScheduler(handler);
Inner inner = scheduler.createInner();
Worker inner = scheduler.createWorker();
inner.schedule(action, 1L, TimeUnit.SECONDS);

// verify that we post to the given Handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import rx.Observable;
import rx.Observer;
import rx.Scheduler;
import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action0;
Expand Down Expand Up @@ -599,7 +599,7 @@ public static <R> Func0<Observable<R>> toAsync(final Func0<? extends R> func, fi
@Override
public Observable<R> call() {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -659,7 +659,7 @@ public static <T1, R> Func1<T1, Observable<R>> toAsync(final Func1<? super T1, ?
@Override
public Observable<R> call(final T1 t1) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -721,7 +721,7 @@ public static <T1, T2, R> Func2<T1, T2, Observable<R>> toAsync(final Func2<? sup
@Override
public Observable<R> call(final T1 t1, final T2 t2) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -785,7 +785,7 @@ public static <T1, T2, T3, R> Func3<T1, T2, T3, Observable<R>> toAsync(final Fun
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -851,7 +851,7 @@ public static <T1, T2, T3, T4, R> Func4<T1, T2, T3, T4, Observable<R>> toAsync(f
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -919,7 +919,7 @@ public static <T1, T2, T3, T4, T5, R> Func5<T1, T2, T3, T4, T5, Observable<R>> t
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -989,7 +989,7 @@ public static <T1, T2, T3, T4, T5, T6, R> Func6<T1, T2, T3, T4, T5, T6, Observab
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -1061,7 +1061,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, R> Func7<T1, T2, T3, T4, T5, T6, T7,
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -1135,7 +1135,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, R> Func8<T1, T2, T3, T4, T5, T6,
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7, final T8 t8) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -1211,7 +1211,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Func9<T1, T2, T3, T4, T5,
@Override
public Observable<R> call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7, final T8 t8, final T9 t9) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -1267,7 +1267,7 @@ public static <R> FuncN<Observable<R>> toAsync(final FuncN<? extends R> func, fi
@Override
public Observable<R> call(final Object... args) {
final AsyncSubject<R> subject = AsyncSubject.create();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down Expand Up @@ -1535,7 +1535,7 @@ public static <T> FutureTask<Void> forEachFuture(
Action1<? super T> onNext,
Scheduler scheduler) {
FutureTask<Void> task = OperationForEachFuture.forEachFuture(source, onNext);
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(Functionals.fromRunnable(task, inner));
return task;
}
Expand Down Expand Up @@ -1563,7 +1563,7 @@ public static <T> FutureTask<Void> forEachFuture(
Action1<? super Throwable> onError,
Scheduler scheduler) {
FutureTask<Void> task = OperationForEachFuture.forEachFuture(source, onNext, onError);
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(Functionals.fromRunnable(task, inner));
return task;
}
Expand Down Expand Up @@ -1593,7 +1593,7 @@ public static <T> FutureTask<Void> forEachFuture(
Action0 onCompleted,
Scheduler scheduler) {
FutureTask<Void> task = OperationForEachFuture.forEachFuture(source, onNext, onError, onCompleted);
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
inner.schedule(Functionals.fromRunnable(task, inner));
return task;
}
Expand Down Expand Up @@ -1800,7 +1800,7 @@ public void call(Subscriber<? super U> t1) {
}
}, csub);

final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
csub.set(inner);

inner.schedule(new Action0() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package rx.util.async.operators;

import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.functions.Action0;
import rx.functions.Action1;

Expand Down Expand Up @@ -66,7 +66,7 @@ public void call() {
* @param run the Runnable to run when the Action0 is called
* @return the Action0 wrapping the Runnable
*/
public static Action0 fromRunnable(Runnable run, Inner inner) {
public static Action0 fromRunnable(Runnable run, Worker inner) {
if (run == null) {
throw new NullPointerException("run");
}
Expand All @@ -75,9 +75,9 @@ public static Action0 fromRunnable(Runnable run, Inner inner) {
/** An Action1 which wraps and calls a Runnable. */
private static final class ActionWrappingRunnable implements Action0 {
final Runnable run;
final Inner inner;
final Worker inner;

public ActionWrappingRunnable(Runnable run, Inner inner) {
public ActionWrappingRunnable(Runnable run, Worker inner) {
this.run = run;
this.inner = inner;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ private NewFiberScheduler() {
}

@Override
public Inner createInner() {
public Worker createWorker() {
return new EventLoopScheduler();
}


private class EventLoopScheduler extends Scheduler.Inner implements Subscription {
private class EventLoopScheduler extends Scheduler.Worker implements Subscription {
private final CompositeSubscription innerSubscription = new CompositeSubscription();

private EventLoopScheduler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public static SwingScheduler getInstance() {
}

@Override
public Inner createInner() {
public Worker createWorker() {
return new InnerSwingScheduler();
}

private static class InnerSwingScheduler extends Inner {
private static class InnerSwingScheduler extends Worker {

private final CompositeSubscription innerSubscription = new CompositeSubscription();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import javax.swing.SwingUtilities;

import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.Subscription;
import rx.functions.Action0;
import rx.schedulers.SwingScheduler;
Expand All @@ -41,7 +41,7 @@ public void call() {
if (SwingUtilities.isEventDispatchThread()) {
unsubscribe.call();
} else {
final Inner inner = SwingScheduler.getInstance().createInner();
final Worker inner = SwingScheduler.getInstance().createWorker();
inner.schedule(new Action0() {
@Override
public void call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.functions.Action0;
import rx.schedulers.SwingScheduler;

Expand All @@ -35,7 +35,7 @@ public static SwingTestHelper create() {
}

public SwingTestHelper runInEventDispatchThread(final Action0 action) {
Inner inner = SwingScheduler.getInstance().createInner();
Worker inner = SwingScheduler.getInstance().createWorker();
inner.schedule(new Action0() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.junit.rules.ExpectedException;
import org.mockito.InOrder;

import rx.Scheduler.Inner;
import rx.Scheduler.Worker;
import rx.functions.Action0;

/**
Expand All @@ -48,7 +48,7 @@ public final class SwingSchedulerTest {
@Test
public void testInvalidDelayValues() {
final SwingScheduler scheduler = new SwingScheduler();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();
final Action0 action = mock(Action0.class);

exception.expect(IllegalArgumentException.class);
Expand All @@ -67,7 +67,7 @@ public void testInvalidDelayValues() {
@Test
public void testPeriodicScheduling() throws Exception {
final SwingScheduler scheduler = new SwingScheduler();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();

final CountDownLatch latch = new CountDownLatch(4);

Expand Down Expand Up @@ -98,7 +98,7 @@ public void call() {
@Test
public void testNestedActions() throws Exception {
final SwingScheduler scheduler = new SwingScheduler();
final Inner inner = scheduler.createInner();
final Worker inner = scheduler.createWorker();

final Action0 firstStepStart = mock(Action0.class);
final Action0 firstStepEnd = mock(Action0.class);
Expand Down
Loading

0 comments on commit 598afbb

Please sign in to comment.