<div dir="ltr"><div>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.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Andrii Lomakin <<a href="mailto:lomakin.andrey@gmail.com">lomakin.andrey@gmail.com</a>> ezt írta (időpont: 2023. jún. 17., Szo, 14:16):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>As for the usage of virtual threads in the UI event loop.</div><div>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). </div><div dir="ltr">But, correct me if I am wrong, channels can also achieve the same effect of allowing other processes to be carried out while waiting.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 17, 2023 at 1:47 PM Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com" target="_blank">attila.kelemen85@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">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.</div></div></blockquote></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><br></div></div></div></div>
</blockquote></div></div>