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

component: Use generational-arena for component storage #113

Merged
merged 1 commit into from
Aug 3, 2019

Conversation

tony-iqlusion
Copy link
Member

The generational-arena crate implements a generational index allocator which provides a "weak ref" for addressing a particular component, implemented in this PR in the form of component::Handle:

https://github.com/fitzgen/generational-arena

This also allows multiple simultaneous mutable references to components, so this PR additionally introduces Component::register_dependency which provides mutable refs to a component and its dependency for each enumerated dependency. In principle this is equivalent to "dependency
injection".

This PR removes the previous downcasting functionality, which was never tested and didn't seem to work out in practice. It should get added back, but in a form that actually works, with tests.

The `generational-arena` crate implements a generational index allocator
which provides a "weak ref" for addressing a particular component,
implemented in this PR in the form of `component::Handle`:

<https://github.com/fitzgen/generational-arena>

This also allows multiple simultaneous mutable references to components,
so this PR additionally introduces `Component::register_dependency`
which provides mutable refs to a component and its dependency for each
enumerated dependency. In principle this is equivalent to "dependency
injection".

This PR removes the previous downcasting functionality, which was never
tested and didn't seem to work out in practice. It should get added
back, but in a form that actually works, with tests.
@tarcieri
Copy link
Collaborator

tarcieri commented Aug 2, 2019

@lberezy this PR might help address some of your concerns (although not all of them).

I intend to backfill some tests after this, but hopefully this is closer to where the component system should be.

This removes the previously useless downcasting functionality. I'd like to bring it back, but with tests to ensure it's actually useful.

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