Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Jan 11, 2025
1 parent 0340772 commit 10ca8ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/pages/1 - Cask - a Scala HTTP micro-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ and pass them all into `cask.Main`.
$$minimalApplicationWithLoom
By cask can support using Virtual Threads to handle the request out of the box, you can enable it with the next steps:
Cask can support using Virtual Threads to handle the request out of the box, you can enable it with the next steps:
1. Running with Java 21 or later
1. Running cask with Java 21 or later
2. add `--add-opens java.base/java.lang=ALL-UNNAMED` to your JVM options, which is needed to name the virtual threads.
3. add `-Dcask.virtual-thread.enabled=true` to your JVM options, which is needed to enable the virtual threads.
4. tweak the underlying carrier threads with `-Djdk.virtualThreadScheduler.parallelism`, `jdk.virtualThreadScheduler.maxPoolSize` and etc.
4. tweak the underlying carrier threads with `-Djdk.virtualThreadScheduler.parallelism`, `jdk.virtualThreadScheduler.maxPoolSize` and `jdk.unparker.maxPoolSize`.
**Advanced Features**:
1. You can change the default scheduler of the carrier threads with `cask.internal.Util.createVirtualThreadExecutor` method, but keep in mind, that's not officially supported.
1. You can change the default scheduler of the carrier threads with `cask.internal.Util.createVirtualThreadExecutor` method, but keep in mind, that's not officially supported by JDK for now.
2. You can supply your own `Executor` by override the `handlerExecutor()` method in your `cask.Main` object, which will be called only once when the server starts.
3. You can use `jdk.internal.misc.Blocker` to help the `ForkJoinPool` when needed.
3. You can use `jdk.internal.misc.Blocker`'s `begin` and `end` methods to help the `ForkJoinPool` when needed.
**NOTE**:
1. If your code is CPU-bound, you should not use virtual threads, because it will not improve the performance, but will increase the overhead.
Expand Down

0 comments on commit 10ca8ec

Please sign in to comment.