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 an 'Entity Lock' type which pauses creation, destruction and thread/script updates while the lock is held #77

Open
ImmutableOctet opened this issue Jul 15, 2024 · 0 comments
Assignees
Labels
C++ Script API Feature New feature or request Idea Ideas, concepts, etc. (for features without a clear scope yet) Memory Safety module: engine For features that involve the `engine` module. (optional) Thread Safety

Comments

@ImmutableOctet
Copy link
Owner

This lock would help prevent critical modifications of an entity from taking place while it is held. Once Entity Threads are running in parallel (e.g. on a thread scheduler), there is currently no guarantee that operations on other entities will be safe.

The idea here is to have a lock type that leverages RAII to ensure the work in the current scope is executed safely. Once the scope is exited, or if e.g. a loop iteration is completed, a different co_await is hit, etc. we can automatically unlock the entity, allowing other work to be performed.

Locks could be made more efficient by associating the entity's 'batch', rather than the entity itself -- we could then use a mutex/critical-section object per-batch.

@ImmutableOctet ImmutableOctet added Feature New feature or request Idea Ideas, concepts, etc. (for features without a clear scope yet) module: engine For features that involve the `engine` module. (optional) C++ Script API labels Jul 15, 2024
@ImmutableOctet ImmutableOctet self-assigned this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Script API Feature New feature or request Idea Ideas, concepts, etc. (for features without a clear scope yet) Memory Safety module: engine For features that involve the `engine` module. (optional) Thread Safety
Projects
None yet
Development

No branches or pull requests

1 participant