Wrapping virtual threads in predefined ExecutorService.

Attila Kelemen attila.kelemen85 at gmail.com
Sat Jun 17 12:20:07 UTC 2023


Kotlin coroutines are cooperative, and they also allow you to use
continuation. Though I don't know their UI framework, in Kotlin's case it
is obviously possible.

Andrii Lomakin <lomakin.andrey at gmail.com> ezt írta (időpont: 2023. jún.
17., Szo, 14:16):

> As for the usage of virtual threads in the UI event loop.
> JetBrains utilizes virtual threads in the Compose Multiplatform UI
> architecture's event loop. Kotlin coroutines accept the dispatcher (or
> carrier thread/pool) and provide await functionality (as you mentioned
> above).
> But, correct me if I am wrong, channels can also achieve the same effect
> of allowing other processes to be carried out while waiting.
>
> On Sat, Jun 17, 2023 at 1:47 PM Attila Kelemen <attila.kelemen85 at gmail.com>
> wrote:
>
>> I agree that it would be useful for a couple of reasons. For example to
>> reduce the maximum latency. I just don't see the benefit for such a tight
>> low level optimization. As for UI: It wouldn't be useful I think, because
>> the UI frameworks are single threaded to avoid synchronization need, and
>> you can't really have that with virtual threads, because virtual thread
>> scheduling is not cooperative. For a UI framework (with `await` like
>> functionality of other languages) you need cooperation where you
>> effectively tell the framework that "while I'm waiting here, you can
>> process other things". That would - I believe - require the exposal of
>> continuation, or some specific support.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230617/1b314036/attachment-0001.htm>


More information about the loom-dev mailing list