-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes #8863 - Provide a possibility to name virtual threads Reworked the VirtualThreads APIs to be based on `Executor` rather than just `boolean`. Introduced Jetty module `threadpool-virtual-preview`. Signed-off-by: Simone Bordet <[email protected]>
- Loading branch information
Showing
11 changed files
with
229 additions
and
43 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
45 changes: 45 additions & 0 deletions
45
jetty-server/src/main/config/etc/jetty-threadpool-virtual-preview.xml
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,45 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> | ||
|
||
<Configure> | ||
<New id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"> | ||
<Set name="name" property="jetty.threadPool.namePrefix" /> | ||
<Set name="minThreads" type="int"><Property name="jetty.threadPool.minThreads" deprecated="threads.min" default="10"/></Set> | ||
<Set name="maxThreads" type="int"><Property name="jetty.threadPool.maxThreads" deprecated="threads.max" default="200"/></Set> | ||
<Set name="reservedThreads" type="int"><Property name="jetty.threadPool.reservedThreads" default="-1"/></Set> | ||
<Set name="idleTimeout" type="int"><Property name="jetty.threadPool.idleTimeout" deprecated="threads.timeout" default="60000"/></Set> | ||
<Set name="detailedDump" type="boolean"><Property name="jetty.threadPool.detailedDump" default="false"/></Set> | ||
<Get id="namePrefix" name="name" /> | ||
<Call class="java.lang.Thread" name="ofVirtual"> | ||
<Call class="java.lang.Thread$Builder" name="name"> | ||
<Arg> | ||
<Property name="jetty.threadPool.virtual.namePrefix"> | ||
<Default><Ref refid="namePrefix" />-virtual-</Default> | ||
</Property> | ||
</Arg> | ||
<Arg type="long">0</Arg> | ||
<Call class="java.lang.Thread$Builder" name="allowSetThreadLocals"> | ||
<Arg type="boolean"><Property name="jetty.threadPool.virtual.allowSetThreadLocals" default="true" /></Arg> | ||
<Call class="java.lang.Thread$Builder" name="inheritInheritableThreadLocals"> | ||
<Arg type="boolean"><Property name="jetty.threadPool.virtual.inheritInheritableThreadLocals" default="false" /></Arg> | ||
<Call id="virtualThreadFactory" class="java.lang.Thread$Builder" name="factory" /> | ||
</Call> | ||
</Call> | ||
</Call> | ||
</Call> | ||
<Call name="setVirtualThreadsExecutor"> | ||
<Arg> | ||
<Call class="java.util.concurrent.Executors" name="newThreadPerTaskExecutor"> | ||
<Arg><Ref refid="virtualThreadFactory" /></Arg> | ||
</Call> | ||
</Arg> | ||
</Call> | ||
</New> | ||
|
||
<Call class="org.slf4j.LoggerFactory" name="getLogger"> | ||
<Arg>org.eclipse.jetty</Arg> | ||
<Call name="warn"> | ||
<Arg>Virtual threads are a Java Preview Feature, support may be limited.</Arg> | ||
</Call> | ||
</Call> | ||
</Configure> |
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
jetty-server/src/main/config/modules/threadpool-virtual-preview.mod
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 @@ | ||
[description] | ||
Enables and configures the Server ThreadPool with support for virtual threads. | ||
|
||
[exec] | ||
--enable-preview | ||
|
||
[depends] | ||
logging | ||
|
||
[provides] | ||
threadpool | ||
|
||
[xml] | ||
etc/jetty-threadpool-virtual-preview.xml | ||
|
||
[ini-template] | ||
## Platform threads name prefix. | ||
#jetty.threadPool.namePrefix=qtp<hashCode> | ||
|
||
## Minimum number of pooled threads. | ||
#jetty.threadPool.minThreads=10 | ||
|
||
## Maximum number of pooled threads. | ||
#jetty.threadPool.maxThreads=200 | ||
|
||
## Number of reserved threads (-1 for heuristic). | ||
#jetty.threadPool.reservedThreads=-1 | ||
|
||
## Thread idle timeout (in milliseconds). | ||
#jetty.threadPool.idleTimeout=60000 | ||
|
||
## Whether to output a detailed dump. | ||
#jetty.threadPool.detailedDump=false | ||
|
||
## Virtual threads name prefix. | ||
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual- | ||
|
||
## Whether virtual threads are allowed to set thread locals. | ||
#jetty.threadPool.virtual.allowSetThreadLocals=true | ||
|
||
## Whether virtual threads inherits the values of inheritable thread locals. | ||
#jetty.threadPool.virtual.allowSetThreadLocals=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
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
Oops, something went wrong.