Skip to content

Commit

Permalink
improves docs
Browse files Browse the repository at this point in the history
Signed-off-by: OlegDokuka <[email protected]>
  • Loading branch information
OlegDokuka committed Nov 14, 2023
1 parent 6d206e4 commit 14bdbf2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
36 changes: 32 additions & 4 deletions reactor-core/src/main/java/reactor/core/scheduler/Schedulers.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public static Scheduler immediate() {
* <p>
* Please note, this implementation is not designed to run tasks on
* {@link VirtualThread}. Please see
* {@link Factory#newThreadPerTaskBoundedElastic(int, int, ThreadFactory)} if you need
* {@link Factory#newBoundedElasticThreadPerTask(int, int, ThreadFactory)} if you need
* {@link VirtualThread} compatible scheduler implementation
*
* @param threadCap maximum number of underlying threads to create
Expand Down Expand Up @@ -373,7 +373,7 @@ public static Scheduler newBoundedElastic(int threadCap, int queuedTaskCap, Stri
* <p>
* Please note, this implementation is not designed to run tasks on
* {@link VirtualThread}. Please see
* {@link Factory#newThreadPerTaskBoundedElastic(int, int, ThreadFactory)} if you need
* {@link Factory#newBoundedElasticThreadPerTask(int, int, ThreadFactory)} if you need
* {@link VirtualThread} compatible scheduler implementation
*
* @param threadCap maximum number of underlying threads to create
Expand Down Expand Up @@ -416,7 +416,7 @@ public static Scheduler newBoundedElastic(int threadCap, int queuedTaskCap, Stri
* <p>
* Please note, this implementation is not designed to run tasks on
* {@link VirtualThread}. Please see
* {@link Factory#newThreadPerTaskBoundedElastic(int, int, ThreadFactory)} if you need
* {@link Factory#newBoundedElasticThreadPerTask(int, int, ThreadFactory)} if you need
* {@link VirtualThread} compatible scheduler implementation
*
* @param threadCap maximum number of underlying threads to create
Expand Down Expand Up @@ -463,7 +463,7 @@ public static Scheduler newBoundedElastic(int threadCap, int queuedTaskCap, Stri
* <p>
* Please note, this implementation is not designed to run tasks on
* {@link VirtualThread}. Please see
* {@link Factory#newThreadPerTaskBoundedElastic(int, int, ThreadFactory)} if you need
* {@link Factory#newBoundedElasticThreadPerTask(int, int, ThreadFactory)} if you need
* {@link VirtualThread} compatible scheduler implementation
*
* @param threadCap maximum number of underlying threads to create
Expand Down Expand Up @@ -1092,10 +1092,38 @@ default Scheduler newBoundedElastic(int threadCap, int queuedTaskCap, ThreadFact
*
* @since 3.6.0
*
* @deprecated in favor of
* @return a new {@link Scheduler} that dynamically creates workers with an upper bound to
* the number of backing threads
*/
default Scheduler newThreadPerTaskBoundedElastic(int threadCap, int queuedTaskCap, ThreadFactory threadFactory) {
return newBoundedElasticThreadPerTask(threadCap, queuedTaskCap, threadFactory);
}



/**
* {@link Scheduler} that dynamically creates a bounded number of Workers.
* <p>
* The maximum number of created thread pools is bounded by the provided {@code threadCap}.
* <p>
* The main difference between {@link BoundedElasticScheduler} and
* {@link BoundedElasticThreadPerTaskScheduler} is that underlying machinery
* allocates a new thread for every new task which is one of the requirements
* for usage with {@link VirtualThread}s
* <p>
* <b>Note:</b> for now this scheduler is available only in Java 21 runtime
*
* @param threadCap maximum number of underlying threads to create
* @param queuedTaskCap maximum number of tasks to enqueue when no more threads can be created. Can be {@link Integer#MAX_VALUE} for unbounded enqueueing.
* @param threadFactory a {@link ThreadFactory} to use each thread initialization
*
* @since 3.6.1
*
* @return a new {@link Scheduler} that dynamically creates workers with an upper bound to
* the number of backing threads
*/
default Scheduler newBoundedElasticThreadPerTask(int threadCap, int queuedTaskCap, ThreadFactory threadFactory) {
return new BoundedElasticThreadPerTaskScheduler(threadCap, queuedTaskCap, threadFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BoundedElasticSchedulerSupplier implements Supplier<Scheduler> {
@Override
public Scheduler get() {
if (DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS) {
return factory.newThreadPerTaskBoundedElastic(DEFAULT_BOUNDED_ELASTIC_SIZE,
return factory.newBoundedElasticThreadPerTask(DEFAULT_BOUNDED_ELASTIC_SIZE,
DEFAULT_BOUNDED_ELASTIC_QUEUESIZE,
Thread.ofVirtual()
.name(LOOM_BOUNDED_ELASTIC + "-", 1)
Expand Down

0 comments on commit 14bdbf2

Please sign in to comment.