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

Incorrect explanation of Unsafe usages #91

Open
KaiserKarel opened this issue Jan 16, 2022 · 2 comments
Open

Incorrect explanation of Unsafe usages #91

KaiserKarel opened this issue Jan 16, 2022 · 2 comments

Comments

@KaiserKarel
Copy link

// - u8 is neither Sync, nor Send;
remarks that u8 is neither Send nor Sync, however u8 has auto-trait implementations for both: https://doc.rust-lang.org/std/primitive.u8.html#impl-Sync

@dsprenkels
Copy link
Contributor

I think a good point is being raised here. I am not sure whether the documentation changed in the meantime, or whether I missed something last time. However, we could update the comment with new argumentation following the current requirements for volatile reads:

@tarcieri
Copy link
Contributor

tarcieri commented Dec 16, 2022

IIUC it's bad to mix volatile and non-volatile operations.

The current implementation seems to be built on a non-volatile read (to load the user-provided u8) but does not make any use of volatile writes.

It seems like it would be better to use volatile_write to write the value to the Choice, and volatile_read to retrieve it, making Choice something of a VolatileCell type, although even that doesn't provide a proper abstraction when used with references, and without Pin it may change locations with moves.

Some other options include cmov-like predication instructions as well as #96

@tarcieri tarcieri mentioned this issue Jun 19, 2024
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

3 participants