Implement LuaThread::close()
Implementation of a close function, marking a thread as finalized.
There is Thread::reset with does exactly the same.
There is
Thread::resetwith does exactly the same.
It requires a function, which we don't have.
This new function, close is meant to mimic coroutine.close, marking it as finished.
Im assuming Thread::reset marks it as resumable again right?
is meant to mimic
coroutine.close, marking it as finished.
I don't think it's mlua goal to replicate functionality of Lua standard library.
The idea behind Thread::reset is to provide support of re-using an existing coroutine without creating a new one. And it's used in mlua async implementation to keep a pool of "async" coroutines to avoid extra GC collections and allocations for temporary objects.
I don't think it's mlua goal to replicate functionality of Lua standard library. I'm currently attempting to use
.close()to make sure a thread cannot be resumed again, and that.status()returnsFinished
Implementation of a close function, marking a thread as finalized.
I actually just came across this limitation when trying to implement Roblox’s task.close in pure rust+mlua. Currently worked around using lua.globals() and getting coroutine.close and then calling it with the thread as argument but it’s a workaround
Implementation of a close function, marking a thread as finalized.
I actually just came across this limitation when trying to implement Roblox’s task.close in pure rust+mlua. Currently worked around using lua.globals() and getting coroutine.close and then calling it with the thread as argument but it’s a workaround
It's currently being used in my own project, here's my implementation of it: https://github.com/rblx-godot/rblx-godot/blob/9222b4e0c0890c34e916180b1933a6564c917c84/src/core/scheduler.rs#L381