Scheduler API Feedback

Remi Forax forax at univ-mlv.fr
Sat Oct 4 13:31:28 UTC 2025


> From: "dreamlike_ocean lei" <dreamlike.vertx at gmail.com>
> To: "loom-dev" <loom-dev at openjdk.java.net>
> Sent: Saturday, October 4, 2025 3:19:10 PM
> Subject: Scheduler API Feedback

> Hello @loom-dev <loom-dev at [ http://openjdk.org/ | openjdk.org ] >,

> I have been enjoying the new POLLER_PER_CARRIER design in the Loom repo and I
> really like the direction it is going.
> While building on top of the latest code, I noticed a couple of issues and would
> like to ask for clarification.

>     1.

> When calling Thread.startVirtualThread , the new virtual thread does not inherit
> the scheduler of the calling virtual thread, but instead uses DEFAULT_SCHEDULER
> . What is the reasoning behind this design? Could there be a mechanism to allow
> implicit inheritance? This would be very helpful for custom schedulers based on
> the per-core model.

I do not know if POLLER_PER_CARRIER works that way or not, 
but the preferred mechanism to get "inheritance" of values between virtual threads is to use a ScopeValue for the value and a StructuredTaskScope to organize the virtual threads. 

>     1.

> The method Thread.VirtualThreadScheduler::current is very helpful, but it seems
> not quite enough. Since Loom already provides the read-only
> builtin.externalView , could we also have a method like
> Thread.VirtualThreadScheduler::scheduler(Thread) ? This would make it easier to
> build better schedulers. For example, I could combine Thread.currentThread with
> Thread.VirtualThreadScheduler.scheduler to decide whether to push a task into a
> local task queue rather than the eventLoop’s MPSC queue.

> Thank you for your time and help.
> Best regards,
> dreamlike li

regards, 
Rémi 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20251004/2cb50c18/attachment.htm>


More information about the loom-dev mailing list