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

Refactor core Lua state and add thread safety assertions #5159

Merged
merged 3 commits into from
Jan 1, 2025

Conversation

ab9rf
Copy link
Member

@ab9rf ab9rf commented Dec 31, 2024

This moves the global Lua state from a static global in LuaTools.h to a member variable of the singleton Core. A public accessor, getLuaState, is added to Core to provide access. This accessor includes an assertion which guarantees that only threads that hold the core mutex attempt to acquire the core lua state. Passing true to getLuaState will bypass the assertion; this should only be used in code that is guaranteed to acquire a CoreSuspender before trying to use the acquired Lua state.

split `CoreDefs.h` from `Core.h` to keep `Core` from being loaded into `RemoteClient`
@ab9rf ab9rf force-pushed the lua-state-in-core branch from 37af5ff to 9483459 Compare December 31, 2024 04:24
@myk002 myk002 merged commit b564975 into DFHack:develop Jan 1, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants