Skip to content
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

Implement LuaThread::close() #517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

RadiantUwU
Copy link
Contributor

Implementation of a close function, marking a thread as finalized.

@khvzak
Copy link
Member

khvzak commented Jan 24, 2025

There is Thread::reset with does exactly the same.

@RadiantUwU
Copy link
Contributor Author

RadiantUwU commented Jan 24, 2025

There is Thread::reset with 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?

@khvzak
Copy link
Member

khvzak commented Jan 24, 2025

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.

@RadiantUwU
Copy link
Contributor Author

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() returns Finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants