Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Direct Access to Scheduler Implementations #907

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion rxjava-core/src/main/java/rx/schedulers/ExecutorScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@
public class ExecutorScheduler extends Scheduler {
private final Executor executor;

/**
* @deprecated Use Schedulers.executor();
* @return
*/
@Deprecated
public ExecutorScheduler(Executor executor) {
this.executor = executor;
}

/**
* @deprecated Use Schedulers.executor();
* @return
*/
@Deprecated
public ExecutorScheduler(ScheduledExecutorService executor) {
this.executor = executor;
}
Expand All @@ -50,7 +60,6 @@ public Subscription schedule(Action1<Scheduler.Inner> action) {
inner.schedule(action);
return inner.innerSubscription;
}


@Override
public Subscription schedule(Action1<Inner> action, long delayTime, TimeUnit unit) {
Expand Down
10 changes: 9 additions & 1 deletion rxjava-core/src/main/java/rx/schedulers/ImmediateScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@
public final class ImmediateScheduler extends Scheduler {
private static final ImmediateScheduler INSTANCE = new ImmediateScheduler();

/**
* @deprecated Use Schedulers.immediate();
* @return
*/
@Deprecated
public static ImmediateScheduler getInstance() {
return INSTANCE;
}

/* package */static ImmediateScheduler instance() {
return INSTANCE;
}

/* package accessible for unit tests */ImmediateScheduler() {
}

Expand All @@ -49,7 +58,6 @@ public Subscription schedule(Action1<Inner> action, long delayTime, TimeUnit uni
return inner.innerSubscription;
}


private class InnerImmediateScheduler extends Scheduler.Inner implements Subscription {

final BooleanSubscription innerSubscription = new BooleanSubscription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@ public Thread newThread(Runnable r) {
}
};

/**
* @deprecated Use Schedulers.newThread();
* @return
*/
@Deprecated
public static NewThreadScheduler getInstance() {
return INSTANCE;
}

/* package */ static NewThreadScheduler instance() {
return INSTANCE;
}

private NewThreadScheduler() {

Expand Down
8 changes: 4 additions & 4 deletions rxjava-core/src/main/java/rx/schedulers/Schedulers.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private Schedulers() {
* @return {@link ImmediateScheduler} instance
*/
public static Scheduler immediate() {
return ImmediateScheduler.getInstance();
return ImmediateScheduler.instance();
}

/**
Expand All @@ -52,7 +52,7 @@ public static Scheduler immediate() {
*/
@Deprecated
public static Scheduler currentThread() {
return TrampolineScheduler.getInstance();
return TrampolineScheduler.instance();
}

/**
Expand All @@ -61,7 +61,7 @@ public static Scheduler currentThread() {
* @return {@link TrampolineScheduler} instance
*/
public static Scheduler trampoline() {
return TrampolineScheduler.getInstance();
return TrampolineScheduler.instance();
}

/**
Expand All @@ -70,7 +70,7 @@ public static Scheduler trampoline() {
* @return {@link NewThreadScheduler} instance
*/
public static Scheduler newThread() {
return NewThreadScheduler.getInstance();
return NewThreadScheduler.instance();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@
public class TrampolineScheduler extends Scheduler {
private static final TrampolineScheduler INSTANCE = new TrampolineScheduler();

/**
* @deprecated Use Schedulers.trampoline();
* @return
*/
@Deprecated
public static TrampolineScheduler getInstance() {
return INSTANCE;
}

/* package */ static TrampolineScheduler instance() {
return INSTANCE;
}

@Override
public Subscription schedule(Action1<Scheduler.Inner> action) {
Expand Down