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

Support items that don't implement Clone, Eq, and PartialEq #17

Open
vadixidav opened this issue Oct 27, 2023 · 1 comment
Open

Support items that don't implement Clone, Eq, and PartialEq #17

vadixidav opened this issue Oct 27, 2023 · 1 comment

Comments

@vadixidav
Copy link

vadixidav commented Oct 27, 2023

Hi, I am not sure if this would make sense to go in this crate, but I am interested in a case where I need an eventually consistent WebGPU Texture which is not Clone, Eq, or PartialEq. It is not important to me if the same exact texture is explicitly written twice and then read twice. Rather, I simply want to ensure that I am not displaying old frames, only the latest frame, in the case that frames are produced faster than the VSync rate.

Given this, would it make sense to add a variant of the Eventual that always wraps the contained item in an Arc and then uses pointer equality (via https://doc.rust-lang.org/std/sync/struct.Arc.html#method.ptr_eq) to satisfy the Eq requirement. This would still have eventual consistency all the same, but it might trigger someone downstream to get the same value twice. For many applications this is acceptable and possibly even required if the resources are too large or time consuming to compare (like GPU memory). In my case I will probably work around this issue by creating a newtype that implements Eq and PartialEq explicitly using Arc::ptr_eq, but I think having something like this in this crate would be useful for others who have a similar problem.

Thoughts?

@vadixidav vadixidav changed the title Support items that don't implement Clone Support items that don't implement Clone, Eq, and PartialEq Oct 27, 2023
@That3Percent
Copy link
Contributor

What you are asking for already exists out of the box in the eventuals library. There is a type Ptr implemented here which I think is exactly as you describe.

I'm a former full-time game developer of ~10 years across AAA & indie and am curious what are you building?

Also, you might be interested in one of my other libraries - second-stack which I used all the time for game engine work and especially writing vertex buffers in WebGL to avoid frequent large allocations. It's an improvement in usability and performance over arena allocation.

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

2 participants