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

Entity deletion (with finalizer support) #4

Closed
SOF3 opened this issue Jul 23, 2022 · 0 comments
Closed

Entity deletion (with finalizer support) #4

SOF3 opened this issue Jul 23, 2022 · 0 comments

Comments

@SOF3
Copy link
Owner

SOF3 commented Jul 23, 2022

Maintain a deletion_flag: Vec<bool> and finalizer_count: Vec<AtomicUsize> for each archetype.

Entity creation

  • Count the components that are finalizers, stored to finalizer_count
  • Initialize deletion_flag as false.

Entity deletion flagging

  • Offline mode: accepts an entity: impl entity::Ref, get the raw ID and drop(entity).
  • Online mode: accepts an entity: impl entity::Ref, get the raw ID, push the raw ID to a sharded queue, process in batch after join.
  • During offline/join: If finalizer count is zero, proceed to "Entity deletion". Otherwise, set deletion_flag to true to wait for trigger from finalizers.

Component update

If a component is removed and the deletion flag for its entity is true, the entity is queued for finalizer test after join.

Entity deletion

  • Check the refcount of the entity, ensure that the internal refcount is the only reference.
  • Loop through all storages, drop the component from the storage if exists.
  • Deallocate the entity ID.
@SOF3 SOF3 closed this as completed Aug 7, 2022
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

1 participant