Single Thread Continuation
Attila Kelemen
attila.kelemen85 at gmail.com
Mon Jul 3 10:58:42 UTC 2023
>
>
> In other words, I'd like to be able to use a set of virtual threads
> that are guaranteed to be scheduled on a single platform thread.
> This is a common approach used inside language interpreters embedded
> into game engines (typically Lua, although I hear C# is seeing use for
> this too nowadays).
>
> Game engines and simulations tend to comprise a large number of
> concurrent tasks, and much of the time those tasks need to access
> complex mutable state that is very difficult to reliably make
> thread-safe. Additionally, most of the time it's desirable for it
> to be possible to pause and resume the execution of individual tasks.
>
>
Even if you could specify that a set of virtual threads must run on the
same platform thread, it would not solve your problem, because virtual
threads are non-cooperative. So, even when there is only one underlying
platform thread, you have to synchronize access to shared mutable state. In
this regard virtual threads and platform threads are not fundamentally
different (at least in principle). Though with continuation available you
could solve your problem I believe.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230703/ff2dc0c9/attachment-0001.htm>
More information about the loom-dev
mailing list