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

Unable to use components that require lifetime parameters #83

Closed
photex opened this issue Dec 2, 2016 · 5 comments · Fixed by #150
Closed

Unable to use components that require lifetime parameters #83

photex opened this issue Dec 2, 2016 · 5 comments · Fixed by #150

Comments

@photex
Copy link

photex commented Dec 2, 2016

Howdy!

I was attempting to play around with radiant and specs but I've run into some trouble. Component requires Any... which requires the static lifetime. So it isn't possible (or it just isn't clear how) to create components that hold runtime resources.

Any advice here?

@photex
Copy link
Author

photex commented Dec 2, 2016

Hrm... I think just realized this is the general case where we'd want a handle map. Is there a generic container out there for this yet? In specs or gfx perhaps?

@kvark
Copy link
Member

kvark commented Dec 2, 2016

@photex Hello, and glad to see you!

I don't think anyone got a need for the lifetimed components. The problem here is that the component storages are accessed from worker threads that run in a thread pool. So in order to put any lifetime constraint these would have to be converted to the scoped threads.

As for the handle map, could you explain in more detail on what it is and where you'd need it?

I'd be very interested to see radiant+specs working together. I'm sure a lot of people are going to be interested in this!

@photex
Copy link
Author

photex commented Dec 2, 2016

o/ @kvark

Most stuff in radiant has an explicit lifetime. For example the Sprite

Sprites can't be created without a RenderContext (also containing a lifetime), and that comes from the Renderer (also has a lifetime). So we can't really load any sprites or fonts without involving these things.

You can wrap a Layer with an Arc and stick that into a System which is handy when making a system for multithreaded updates and issuing draw commands. But when trying to create a Sprite component this issue came up.

So, you start your app or level, load your assets, and initialize entities and here is where I imagined the need for a handle map because I don't know how we can associate sprite resources with a component any other way. :)
Handle map may be the wrong name, but isn't that how gfx is managing it's resources? another example

@photex
Copy link
Author

photex commented Dec 4, 2016

I think we've found a solution using only what's at hand.

Our render system has a Sender to our main thread to submit draw commands (which are just enum values). The Sprite component just has a handle to a sprite which it includes and a layer id.

Not the final design but it's functioning within all the constraints. We avoid referring to any radiant stuff directly within our ECS related code.

@sinesc
Copy link

sinesc commented Jan 20, 2017

I have since removed lifetime requirements from Sprite and a bunch of other things.

xMAC94x pushed a commit to xMAC94x/specs that referenced this issue Mar 10, 2021
83: Make a 0.7-alpha1 pre-release r=torkleyy a=torkleyy

cc @Rhuagh @omni-viral @Xaeroxe @WaDelma 

I intend to release pre-release versions of shred and Specs today so we can check if everything is working as intended.

Co-authored-by: torkleyy <[email protected]>
xMAC94x pushed a commit to xMAC94x/specs that referenced this issue Mar 10, 2021
143: Update hashbrown requirement from 0.4.0 to 0.5.0 r=torkleyy a=dependabot-preview[bot]

Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
<details>
<summary>Changelog</summary>

*Sourced from [hashbrown's changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md).*

> ## [v0.5.0] - 2019-06-12
> 
> ### Fixed
> - Resize with a more conservative amount of space after deletions. ([amethyst#86](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/86))
> 
> ### Changed
> - Exposed the Layout of the failed allocation in CollectionAllocErr::AllocErr. ([amethyst#89](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/89))
> 
> ## [v0.4.0] - 2019-05-30
> 
> ### Fixed
> - Fixed `Send` trait bounds on `IterMut` not matching the libstd one. ([amethyst#82](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/82))
> 
> ## [v0.3.1] - 2019-05-30
> 
> ### Fixed
> - Fixed incorrect use of slice in unsafe code. ([amethyst#80](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/80))
> 
> ## [v0.3.0] - 2019-04-23
> 
> ### Changed
> - Changed shrink_to to not panic if min_capacity < capacity. ([amethyst#67](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/67))
> 
> ### Fixed
> - Worked around emscripten bug emscripten-core/emscripten-fastcomp#258. ([amethyst#66](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/66))
> 
> ## [v0.2.2] - 2019-04-16
> 
> ### Fixed
> - Inlined non-nightly lowest_set_bit_nonzero. ([amethyst#64](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/64))
> - Fixed build on latest nightly. ([amethyst#65](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/65))
> 
> ## [v0.2.1] - 2019-04-14
> 
> ### Changed
> - Use for_each in map Extend and FromIterator. ([amethyst#58](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/58))
> - Improved worst-case performance of HashSet.is_subset. ([amethyst#61](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/61))
> 
> ### Fixed
> - Removed incorrect debug_assert. ([amethyst#60](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/60))
> 
> ## [v0.2.0] - 2019-03-31
> 
> ### Changed
> - The code has been updated to Rust 2018 edition. This means that the minimum
>   Rust version has been bumped to 1.31 (2018 edition).
> 
> ### Added
> - Added `insert_with_hasher` to the raw_entry API to allow `K: !(Hash + Eq)`. ([amethyst#54](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/54))
> - Added support for using hashbrown as the hash table implementation in libstd. ([amethyst#46](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/46))
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`e7cd4a5`](rust-lang/hashbrown@e7cd4a5) Version 0.5.0
- [`2c16341`](rust-lang/hashbrown@2c16341) Auto merge of [amethyst#89](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/89) - SimonSapin:layout, r=Amanieu
- [`c2e26e7`](rust-lang/hashbrown@c2e26e7) Expose the Layout of the failed allocation in CollectionAllocErr::AllocErr
- [`14bb115`](rust-lang/hashbrown@14bb115) Auto merge of [amethyst#87](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/87) - josephrocca:patch-1, r=Amanieu
- [`80dc544`](rust-lang/hashbrown@80dc544) Add simple usage code
- [`b240ee0`](rust-lang/hashbrown@b240ee0) Auto merge of [amethyst#86](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/86) - edre:rehash, r=Amanieu
- [`afc20d7`](rust-lang/hashbrown@afc20d7) Resize with a more conservative amount of space when inserting after deletions.
- [`119f429`](rust-lang/hashbrown@119f429) Auto merge of [amethyst#84](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/84) - edre:bench, r=Amanieu
- [`8783490`](rust-lang/hashbrown@8783490) Update insert_erase benchmark to keep the table size constant.
- [`143609d`](rust-lang/hashbrown@143609d) Auto merge of [amethyst#83](https://github-redirect.dependabot.com/rust-lang/hashbrown/issues/83) - edre:bench, r=Amanieu
- Additional commits viewable in [compare view](rust-lang/hashbrown@v0.4.0...v0.5.0)
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>

Co-authored-by: dependabot-preview[bot] <dependabot-preview[bot]@users.noreply.github.com>
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 a pull request may close this issue.

3 participants