Coroutine questions
Alan Bateman
alan.bateman at oracle.com
Tue Mar 18 17:21:06 UTC 2025
On 18/03/2025 16:39, common1945 at tutanota.com wrote:
> I am doing some experiments that will make use of loom's Continuation
> with jdk22+. I know that I can achieve java Continuation effect with
> following code. However, I have a few questions:
>
> 1. Is it possible to pass in arguments like Lua's coroutine[1][2]?
> 2. Is it possible to yield/ return some values like Lua's
> coroutine[1][2]?
> 3. Does the way to communicate between the Continuation block i.e.
> Runnable and outside Runnable merely be able to achieved by
> embedding e.g. BlockingQueue inside the Runnable code block?
> 4. Is it possible to capture Continuation's snapshot for later use?
>
I don't want to spoil your experiments but just to say that the internal
Continuation API that you found is not intended to be used directly,
isn't documented, and may change at any time. For Lua like passing of
parameters from resume to yield then you can extend Continuation to add
a field for the passed parameter.
By snapshot I assume you mean being able to serialize and resume in a
different VM. There isn't any support for that.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250318/69d144ed/attachment.htm>
More information about the loom-dev
mailing list