How does the loop feature work and how could it be expanded #56
Replies: 1 comment
-
Correct.
No. What you pass to
No.
Yes. You can trigger the callback from any thread (
Probably not. There's no way to poll anything via What you could do is create a new single threaded tokio runtime,
It might be a little misleading but I followed the original |
Beta Was this translation helpful? Give feedback.
-
The new
loop
feature provides access to ther#loop::new_async
function and I was wondering how it works under the hood. The example callsAsyncHandle::send
after pushing into the channel so I guess what really happens is that via thenew_async
function we can create some kind of task which is advanced everytime we callsend
on the returned handle. Advancing means it runs until the task yields I guess? (which would happen if we callblocking_recv
and there are no items in the channel)If those observations are correct I guess my question is on which thread that task is executed? Supposedly on the Neovim thread because we can access the lua context inside the task?
I wonder if it would be possible to make the passed in closure return a future and then poll it everytime
send
is called? An async executor like tokio could be used on another thread to repeatedly callsend
until the task completed? Is this possible? I think it would add to the feature, as currently even though the method is callednew_async
we can not actually use async await.If not possible we can maybe choose a different name?
Beta Was this translation helpful? Give feedback.
All reactions