-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Can build native image again. Don't use virtual threads on native i…
…mage, since GraalVM still doesn't support it.
- Loading branch information
Showing
13 changed files
with
154 additions
and
47 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,16 @@ | |
|
||
import io.undertow.server.HttpServerExchange; | ||
import io.undertow.server.handlers.BlockingHandler; | ||
import org.restheart.graal.ImageInfo; | ||
|
||
/** | ||
* | ||
* @author Andrea Di Cesare {@literal <[email protected]>} | ||
* | ||
* Dispatches the execution of the service to the Working Thread Pool | ||
* | ||
* Unless running as a native image, it uses Virtual Threads Executor | ||
* | ||
* This applies to Services annotated | ||
* with @RegisterPlugin(blocking=true) | ||
* | ||
|
@@ -43,7 +46,14 @@ | |
*/ | ||
public class WorkingThreadsPoolDispatcher extends PipelinedHandler { | ||
private final BlockingHandler blockingHandler = new BlockingHandler(this); | ||
private static final Executor virtualThreadsExecutor = ThreadsUtils.virtualThreadsExecutor(); | ||
private static final Executor virtualThreadsExecutor; | ||
|
||
static { | ||
// As GraalVM version 23.1.2 Virtual threads are not supported together with Truffle JIT compilation. | ||
virtualThreadsExecutor = ImageInfo.inImageCode() | ||
? null | ||
: ThreadsUtils.threadsExecutor(); | ||
} | ||
|
||
/** | ||
* Creates a new instance of WorkingThreadsPoolDispatcher | ||
|
@@ -69,7 +79,9 @@ public WorkingThreadsPoolDispatcher(PipelinedHandler next) { | |
*/ | ||
@Override | ||
public void handleRequest(HttpServerExchange exchange) throws Exception { | ||
exchange.setDispatchExecutor(virtualThreadsExecutor); | ||
if (virtualThreadsExecutor != null) { | ||
exchange.setDispatchExecutor(virtualThreadsExecutor); | ||
} | ||
|
||
if (exchange.isInIoThread()) { | ||
blockingHandler.handleRequest(exchange); | ||
|
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
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
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