Custom Schedulers: Customize current time and timed waits
Quinn Klassen
quinn.klassen at temporal.io
Sun Jun 22 17:07:29 UTC 2025
Hello,
I was experimenting with the custom scheduler feature, trying to integrate
it into the open-source library I maintain. For the core part of this
library to work we need to have control/intercept certain parts of the
environment, relevant here are:
1. How threads are scheduled and executed
2. The current time
3. How threads sleep
Since the JVM does not provide a good way to customize these we have to
disallow users from using many normal Java standard library functions and
instead they have to use our custom functions that do allow this. For
example, users have to call `Workflow.sleep` instead of `Thread.sleep`.
Experimenting with the custom schedules it seems like we now could control
how threads are scheduled and executed (amazing!), but we still can't
control the current time or how threads sleep. For example if a thread with
a custom scheduler calls `Thread.sleep` there is no way for the scheduler
to control when that will return, even if the scheduler tries to unpark the
thread the `for` loop in `VirtualThread.sleepNanos` will keep parking it.
In other languages that support a custom scheduler for tasks like Python,
Javascript, Dotnet, Rust or Ruby this sort of behaviour is customizable.
Is there a way currently to customize this behaviour that I have missed or
would this be something the team would be open to exploring in the future?
Thanks,
Quinn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250622/089522b2/attachment-0001.htm>
More information about the loom-dev
mailing list