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

Wrapper for volatile fields #4130

Open
tgross35 opened this issue Nov 21, 2024 · 1 comment
Open

Wrapper for volatile fields #4130

tgross35 opened this issue Nov 21, 2024 · 1 comment

Comments

@tgross35
Copy link
Contributor

In C, fields can be defined as volatile whereas for Rust it is the accesses. I'm wondering if we should consider wrapping any volatile members in some UnsafeCell-based wrapper to ensure they aren't read by accident.

Unfortunately this is a bit tricky since we can't allow it to be moved by the compiler.

@tgross35 tgross35 added this to the 1.0 milestone Nov 21, 2024
@tgross35
Copy link
Contributor Author

I'm thinking maybe we should provide a struct Volatile<T>(UnsafeCell<T>); wrapper type that at least makes it clear what these fields are, even if we can't actually enforce volatility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant