Skip to content

Commit

Permalink
2.x: Expose the Keep-Alive value of the IO Scheduler as System proper…
Browse files Browse the repository at this point in the history
…ty. (#6279) (#6287)
  • Loading branch information
pawellozinski authored and akarnokd committed Nov 5, 2018
1 parent 3281b02 commit 6478312
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public final class IoScheduler extends Scheduler {
private static final String EVICTOR_THREAD_NAME_PREFIX = "RxCachedWorkerPoolEvictor";
static final RxThreadFactory EVICTOR_THREAD_FACTORY;

private static final long KEEP_ALIVE_TIME = 60;
/** The name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers. */
private static final String KEY_KEEP_ALIVE_TIME = "rx2.io-keep-alive-time";
public static final long KEEP_ALIVE_TIME_DEFAULT = 60;

private static final long KEEP_ALIVE_TIME;
private static final TimeUnit KEEP_ALIVE_UNIT = TimeUnit.SECONDS;

static final ThreadWorker SHUTDOWN_THREAD_WORKER;
Expand All @@ -45,7 +49,10 @@ public final class IoScheduler extends Scheduler {
private static final String KEY_IO_PRIORITY = "rx2.io-priority";

static final CachedWorkerPool NONE;

static {
KEEP_ALIVE_TIME = Long.getLong(KEY_KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_DEFAULT);

SHUTDOWN_THREAD_WORKER = new ThreadWorker(new RxThreadFactory("RxCachedThreadSchedulerShutdown"));
SHUTDOWN_THREAD_WORKER.dispose();

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/reactivex/schedulers/Schedulers.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* <p>
* <strong>Supported system properties ({@code System.getProperty()}):</strong>
* <ul>
* <li>{@code rx2.io-keep-alive-time} (long): sets the keep-alive time of the {@link #io()} Scheduler workers, default is {@link IoScheduler#KEEP_ALIVE_TIME_DEFAULT}</li>
* <li>{@code rx2.io-priority} (int): sets the thread priority of the {@link #io()} Scheduler, default is {@link Thread#NORM_PRIORITY}</li>
* <li>{@code rx2.computation-threads} (int): sets the number of threads in the {@link #computation()} Scheduler, default is the number of available CPUs</li>
* <li>{@code rx2.computation-priority} (int): sets the thread priority of the {@link #computation()} Scheduler, default is {@link Thread#NORM_PRIORITY}</li>
Expand Down Expand Up @@ -155,6 +156,7 @@ public static Scheduler computation() {
* before the {@link Schedulers} class is referenced in your code.
* <p><strong>Supported system properties ({@code System.getProperty()}):</strong>
* <ul>
* <li>{@code rx2.io-keep-alive-time} (long): sets the keep-alive time of the {@link #io()} Scheduler workers, default is {@link IoScheduler#KEEP_ALIVE_TIME_DEFAULT}</li>
* <li>{@code rx2.io-priority} (int): sets the thread priority of the {@link #io()} Scheduler, default is {@link Thread#NORM_PRIORITY}</li>
* </ul>
* <p>
Expand Down

0 comments on commit 6478312

Please sign in to comment.