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.
Uh oh!
There was an error while loading. Please reload this page.
-
The new
loopfeature provides access to ther#loop::new_asyncfunction and I was wondering how it works under the hood. The example callsAsyncHandle::sendafter pushing into the channel so I guess what really happens is that via thenew_asyncfunction we can create some kind of task which is advanced everytime we callsendon the returned handle. Advancing means it runs until the task yields I guess? (which would happen if we callblocking_recvand 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
sendis called? An async executor like tokio could be used on another thread to repeatedly callsenduntil the task completed? Is this possible? I think it would add to the feature, as currently even though the method is callednew_asyncwe 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