-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thread into_async should be generic on args #508
Comments
Could you provide more details/example please? |
I probably better remove |
The issue right now is that the returned AsyncThread is a AsyncThread<impl IntoLuaMulti, R> which cannot be (easily) put in a struct. So the below is not possible: pub struct A { a: AsyncThread<LuaMultiValue, LuaMultiValue> }
A {a: thread.into_async::<LuaMultiValue>(args) } // Assume args is a LuaMultiValue for sake of brevity Due to the lack of genericizing on args, rust does not realise that the A of AsyncThread is actually a LuaMultiValue (from args) leading to a value that cannot be (easily) put into a struct and can basically only exist as a variable.
This is probably the better long-term option yeah. |
Unfortunately both options are a breaking change. I committed to the dev branch the new approach with pushing args to the thread during |
This fixes the issue (still need to figure out the task lib stuff but the mlua AsyncThread works fine in structs now + can be reused at least for a perf improvement) |
@khvzak In addition to this, can a yield method (lua_yield in C API) be added to mlua. Right now, this forces me to use a small luau wrapper script to just do coroutine.yield() |
@khvzak Also, can |
It will not work since you cannot yield across C/Rust-call boundary. |
Btw, do you mind reviewing #513 |
Right now, Thread::into_async is not really usable because it returns a AsyncThread<impl IntoLuaMulti, R> where the impl IntoLuaMulti is the same as A:
Instead, this should probably use a second type parameter of A in into_async to allow for rust to correctly infer the type using the passed value for
args
like so:The text was updated successfully, but these errors were encountered: