Change AsyncThread<A, R> to AsyncThread<R>.

Push arguments in `Thread::into_async()` to the thread during the call instead of first poll.
The pushed arguments will be automatically used on resume.
Fixes #508 and relates to #500.
This commit is contained in:
Alex Orlenko
2025-01-11 22:03:32 +00:00
parent cf71edc492
commit ea5ecccf02
3 changed files with 156 additions and 83 deletions
+3 -3
View File
@@ -161,10 +161,10 @@ impl Function {
{
let lua = self.0.lua.lock();
let thread_res = unsafe {
lua.create_recycled_thread(self).map(|th| {
let mut th = th.into_async(args);
lua.create_recycled_thread(self).and_then(|th| {
let mut th = th.into_async(args)?;
th.set_recyclable(true);
th
Ok(th)
})
};
async move { thread_res?.await }