-
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.
Merge pull request #3865 from katzyn/loom
Add possibility to enable virtual worker threads in TCP, Web, and PG servers on Java 21+
- Loading branch information
Showing
15 changed files
with
154 additions
and
7 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
Binary file not shown.
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,36 @@ | ||
/* | ||
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, | ||
* and the EPL 1.0 (https://h2database.com/html/license.html). | ||
* Initial Developer: H2 Group | ||
*/ | ||
package org.h2.util; | ||
|
||
import java.lang.Thread.Builder.OfVirtual; | ||
|
||
/** | ||
* Utilities with specialized implementations for Java 21 and later versions. | ||
* | ||
* This class contains basic implementations for older versions of Java and it | ||
* is overridden in multi-release JARs. | ||
*/ | ||
public final class Utils21 { | ||
|
||
private static final OfVirtual VIRTUAL_THREAD_BUILDER = Thread.ofVirtual(); | ||
|
||
/** | ||
* Creates a new virtual thread (on Java 21+) for the specified task. Use | ||
* {@link Thread#start()} to schedule the thread to execute. On older | ||
* versions of Java a platform daemon thread is created instead. | ||
* | ||
* @param task | ||
* the object to run | ||
* @return a new thread | ||
*/ | ||
public static Thread newVirtualThread(Runnable task) { | ||
return VIRTUAL_THREAD_BUILDER.unstarted(task); | ||
} | ||
|
||
private Utils21() { | ||
} | ||
|
||
} |
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,14 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<!-- | ||
Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, | ||
and the EPL 1.0 (https://h2database.com/html/license.html). | ||
Initial Developer: H2 Group | ||
--> | ||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | ||
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title> | ||
Javadoc package documentation | ||
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p> | ||
|
||
Internal utility classes reimplemented for Java 21 and later versions. | ||
|
||
</p></body></html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, | ||
* and the EPL 1.0 (https://h2database.com/html/license.html). | ||
* Initial Developer: H2 Group | ||
*/ | ||
package org.h2.util; | ||
|
||
/** | ||
* Utilities with specialized implementations for Java 21 and later versions. | ||
* | ||
* This class contains basic implementations for older versions of Java and it | ||
* is overridden in multi-release JARs. | ||
*/ | ||
public final class Utils21 { | ||
|
||
/* | ||
* Signatures of methods should match with | ||
* h2/src/java21/src/org/h2/util/Utils21.java and precompiled | ||
* h2/src/java21/precompiled/org/h2/util/Utils21.class. | ||
*/ | ||
|
||
/** | ||
* Creates a new virtual thread (on Java 21+) for the specified task. Use | ||
* {@link Thread#start()} to schedule the thread to execute. On older | ||
* versions of Java a platform daemon thread is created instead. | ||
* | ||
* @param task | ||
* the object to run | ||
* @return a new thread | ||
*/ | ||
public static Thread newVirtualThread(Runnable task) { | ||
Thread thread = new Thread(task); | ||
thread.setDaemon(true); | ||
return thread; | ||
} | ||
|
||
private Utils21() { | ||
} | ||
|
||
} |
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