-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: OlegDokuka <[email protected]>
- Loading branch information
Oleh Dokuka
committed
Jun 30, 2023
1 parent
29ca754
commit 86a9c8f
Showing
6 changed files
with
139 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
reactor-core/src/main/java/reactor/core/scheduler/BoundedElasticSchedulerSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2023 VMware Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package reactor.core.scheduler; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import reactor.util.Logger; | ||
import reactor.util.Loggers; | ||
|
||
import static reactor.core.scheduler.Schedulers.BOUNDED_ELASTIC; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_SIZE; | ||
import static reactor.core.scheduler.Schedulers.newBoundedElastic; | ||
|
||
class BoundedElasticSchedulerSupplier implements Supplier<Scheduler> { | ||
|
||
static final Logger logger = Loggers.getLogger(BoundedElasticSchedulerSupplier.class); | ||
|
||
@Override | ||
public Scheduler get() { | ||
if (DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS) { | ||
logger.warn( | ||
"Virtual Threads support is not available on the given JVM. Fallbacks to default BoundedElastic setup"); | ||
} | ||
|
||
return newBoundedElastic(DEFAULT_BOUNDED_ELASTIC_SIZE, | ||
DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, | ||
BOUNDED_ELASTIC, | ||
BoundedElasticScheduler.DEFAULT_TTL_SECONDS, | ||
true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
reactor-core/src/main/java21/reactor/core/scheduler/BoundedElasticSchedulerSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2023 VMware Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package reactor.core.scheduler; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import static reactor.core.scheduler.Schedulers.BOUNDED_ELASTIC; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE; | ||
import static reactor.core.scheduler.Schedulers.DEFAULT_BOUNDED_ELASTIC_SIZE; | ||
import static reactor.core.scheduler.Schedulers.LOOM_BOUNDED_ELASTIC; | ||
import static reactor.core.scheduler.Schedulers.newBoundedElastic; | ||
|
||
class BoundedElasticSchedulerSupplier implements Supplier<Scheduler> { | ||
|
||
@Override | ||
public Scheduler get() { | ||
if (DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS) { | ||
return newBoundedElastic(DEFAULT_BOUNDED_ELASTIC_SIZE, | ||
DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, | ||
Thread.ofVirtual() | ||
.name(LOOM_BOUNDED_ELASTIC + "-", 1) | ||
.uncaughtExceptionHandler(Schedulers::defaultUncaughtException) | ||
.factory(), | ||
BoundedElasticScheduler.DEFAULT_TTL_SECONDS); | ||
} | ||
return newBoundedElastic(DEFAULT_BOUNDED_ELASTIC_SIZE, | ||
DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, | ||
BOUNDED_ELASTIC, | ||
BoundedElasticScheduler.DEFAULT_TTL_SECONDS, | ||
true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters