-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vertx: use DevModeExecutorService in the dev mode
- in dev mode we use a special executor for the worker pool where the underlying executor can be shut down and then replaced with a new re-initialized executor - this is a workaround to solve the problem described in #16833 (comment) - the Vertx instance is reused between restarts but we must attempt to shut down this executor, for example to cancel/interrupt the scheduled methods
- Loading branch information
Showing
6 changed files
with
109 additions
and
2 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
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
42 changes: 42 additions & 0 deletions
42
...ons/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/DevModeExecutorService.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,42 @@ | ||
package io.quarkus.vertx.core.runtime; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* This executor is only used in the dev mode as the Vertx worker thread pool. | ||
* <p> | ||
* The underlying executor can be shut down and then replaced with a new re-initialized executor. | ||
*/ | ||
class DevModeExecutorService extends ForwardingExecutorService { | ||
|
||
private static final Logger LOG = Logger.getLogger(DevModeExecutorService.class); | ||
|
||
private final Supplier<ExecutorService> initializer; | ||
private volatile ExecutorService executor; | ||
|
||
DevModeExecutorService(Supplier<ExecutorService> initializer) { | ||
this.initializer = initializer; | ||
this.executor = initializer.get(); | ||
} | ||
|
||
@Override | ||
protected ExecutorService delegate() { | ||
return executor; | ||
} | ||
|
||
/** | ||
* Shutdown the underlying executor and then initialize a new one. | ||
*/ | ||
void reinit() { | ||
ExecutorService oldExecutor = this.executor; | ||
if (oldExecutor != null) { | ||
oldExecutor.shutdownNow(); | ||
} | ||
this.executor = initializer.get(); | ||
LOG.debug("Dev mode executor re-initialized"); | ||
} | ||
|
||
} |
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