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

Feature Request:Implement a LuaAPI.force_stop method #186

Closed
RadiantUwU opened this issue Nov 10, 2023 · 5 comments
Closed

Feature Request:Implement a LuaAPI.force_stop method #186

RadiantUwU opened this issue Nov 10, 2023 · 5 comments

Comments

@RadiantUwU
Copy link
Contributor

RadiantUwU commented Nov 10, 2023

Is your feature request related to a problem? Please describe.
What if the game just wants to stop everything? It cant just know what was bound or not using signals can it? This is where this method would come into play.

Describe the solution you'd like
To efficiently shut down everything, all that would be needed to do is to clear the global table and register table and let the garbage collector do its thing. If there are reference cycles (which would be something very possible), an even better way would be to track what coroutines exist somewhere and then to close them all. If possible, this could be substituted with the lua_closestate to do it all.

Describe alternatives you've considered
Having to do it manually from a protected environment. This would mean running some lua code to initialize the API with the debug library active to allow that code to lock everything down and then to run the said code inside the now protected environment. On a shutdown call, it would do exactly as described before. This would also mean that coroutine.create and coroutine.wrap would require modification to track them somewhere.

@RadiantUwU RadiantUwU changed the title Feature Request:Implement a force_stop method Feature Request:Implement a LuaAPI.force_stop method Nov 10, 2023
@Trey2k
Copy link
Member

Trey2k commented Nov 10, 2023

Handling shutdown is on the game. You dont need any lua side code to do this. You just keep track of all states and do whats required to make them stop gracefully. IE using a hook if you need to force the state to stop or otherwise telling the script to stop.

This library helps a lot but state management is out of scope of what I am aiming to do.

EDIT:
Also, to properly close the lua state as to clear references all you must do is remove all references to the LuaAPI object.

@RadiantUwU
Copy link
Contributor Author

Handling shutdown is on the game. You dont need any lua side code to do this. You just keep track of all states and do whats required to make them stop gracefully. IE using a hook if you need to force the state to stop or otherwise telling the script to stop.

This library helps a lot but state management is out of scope of what I am aiming to do.

EDIT: Also, to properly close the lua state as to clear references all you must do is remove all references to the LuaAPI object.

This wont work for when callables are properly implemented as they will have callables hooked up to it and those callables will have a reference.

@RadiantUwU
Copy link
Contributor Author

Anyways to properly fix this there will be needed a modification to what is gonna be inside the callablecustom, for example when the luaAPI has called force_stop it would then release the reference and return without actually calling it, so that way it is actually detached.

@Trey2k
Copy link
Member

Trey2k commented Nov 17, 2023

This wont work for when callables are properly implemented as they will have callables hooked up to it and those callables will have a reference.

This is inaccurate. It was when the comment was made but I was waiting on changes to be made to the GDExtension side of CallableCustoms that made storing the reference of the object no longer required. So when #180 is merged all we will store is the ObjectID and not the Object its self.

@Trey2k
Copy link
Member

Trey2k commented Nov 17, 2023

You can also utilize the lua garbage collector with the methods we have exposed for that in order to purge references from with the lua state.

@RadiantUwU RadiantUwU closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2023
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

No branches or pull requests

2 participants