Skip to content

Commit

Permalink
chore: Add doc about virtual thread executor. (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin authored Jan 21, 2025
1 parent 373c07a commit 189c893
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/src/main/paradox/typed/dispatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ it in `application.conf` and instantiate through an

## More dispatcher configuration examples

### Virtual Threads

Configuring a dispatcher with virtual threads, requires Java 21 or above:

@@snip [DispatcherDocSpec.scala](/docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala) { #virtual-thread-dispatcher-config }

With this, an actor will run in a virtual thread, so you may want to configure it further with :
`jdk.virtualThreadScheduler.parallelism` ,`jdk.virtualThreadScheduler.maxPoolSize` and `jdk.unparker.maxPoolSize`.

### Fixed pool size

Configuring a dispatcher with fixed thread pool size, e.g. for actors that perform blocking IO:
Expand Down
8 changes: 7 additions & 1 deletion docs/src/test/scala/docs/dispatcher/DispatcherDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ object DispatcherDocSpec {
# Set to 1 for as fair as possible.
throughput = 100
}
//#affinity-pool-dispatcher-config
//#affinity-pool-dispatcher-config
//#virtual-thread-dispatcher-config
virtual-thread-dispatcher {
executor = virtual-thread-executor
}
//#virtual-thread-dispatcher-config
//#fixed-pool-size-dispatcher-config
blocking-io-dispatcher {
Expand Down

0 comments on commit 189c893

Please sign in to comment.