Skip to content

Commit 22b6b3d

Browse files
Merge pull request #725 from benjchristensen/schedulers-naming
Simpler computation/io naming for Schedulers
2 parents 1363f61 + e2c31c2 commit 22b6b3d

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

rxjava-core/src/main/java/rx/schedulers/Schedulers.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,28 @@ public static Scheduler executor(ScheduledExecutorService executor) {
8989
* <p>
9090
* This can be used for event-loops, processing callbacks and other computational work.
9191
* <p>
92-
* Do not perform IO-bound work on this scheduler. Use {@link #threadPoolForComputation()} instead.
92+
* Do not perform IO-bound work on this scheduler. Use {@link #io()} instead.
9393
*
9494
* @return {@link ExecutorScheduler} for computation-bound work.
95+
* @Deprecated Use {@link #computation()}
9596
*/
97+
@Deprecated
9698
public static Scheduler threadPoolForComputation() {
9799
return executor(COMPUTATION_EXECUTOR);
98100
}
101+
102+
/**
103+
* {@link Scheduler} intended for computational work.
104+
* <p>
105+
* This can be used for event-loops, processing callbacks and other computational work.
106+
* <p>
107+
* Do not perform IO-bound work on this scheduler. Use {@link #io()} instead.
108+
*
109+
* @return {@link Scheduler} for computation-bound work.
110+
*/
111+
public static Scheduler computation() {
112+
return executor(COMPUTATION_EXECUTOR);
113+
}
99114

100115
/**
101116
* {@link Scheduler} intended for IO-bound work.
@@ -104,13 +119,30 @@ public static Scheduler threadPoolForComputation() {
104119
* <p>
105120
* This can be used for asynchronously performing blocking IO.
106121
* <p>
107-
* Do not perform computational work on this scheduler. Use {@link #threadPoolForComputation()} instead.
122+
* Do not perform computational work on this scheduler. Use {@link #computation()} instead.
108123
*
109124
* @return {@link ExecutorScheduler} for IO-bound work.
125+
* @deprecated Use {@link #io()} instead.
110126
*/
127+
@Deprecated
111128
public static Scheduler threadPoolForIO() {
112129
return executor(IO_EXECUTOR);
113130
}
131+
132+
/**
133+
* {@link Scheduler} intended for IO-bound work.
134+
* <p>
135+
* The implementation is backed by an {@link Executor} thread-pool that will grow as needed.
136+
* <p>
137+
* This can be used for asynchronously performing blocking IO.
138+
* <p>
139+
* Do not perform computational work on this scheduler. Use {@link #computation()} instead.
140+
*
141+
* @return {@link ExecutorScheduler} for IO-bound work.
142+
*/
143+
public static Scheduler io() {
144+
return executor(IO_EXECUTOR);
145+
}
114146

115147
private static ScheduledExecutorService createComputationExecutor() {
116148
int cores = Runtime.getRuntime().availableProcessors();

0 commit comments

Comments
 (0)