-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add data_ptr method to Mutex and RwLock #140369
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
Conversation
This seems fine to me, but libs-api didn't specify an exact API so I'll ask them to review. r? @Amanieu |
Can you add this for Also add a sentence to the docs saying that you are responsible for ensuring that accesses to the data are synchronized properly. |
This comment has been minimized.
This comment has been minimized.
e9bc1d1
to
20589bd
Compare
I wasn't previously familiar with the unstable Do you have any comments about the unresolved questions? |
@bors r+ |
Add data_ptr method to Mutex and RwLock Implementation of #140368 / rust-lang/libs-team#531. I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course. Unresolved questions: - Return a `LockResult` or not? - Return `*mut T` like existing APIs (`Cell::as_ptr` / `MaybeUninit::as[_mut]_ptr` / `Vec::as_ptr` / ...) or be more precise and return `NonNull<T>`?
💥 Test timed out |
…manieu Add data_ptr method to Mutex and RwLock Implementation of rust-lang#140368 / rust-lang/libs-team#531. I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course. Unresolved questions: - Return a `LockResult` or not? - Return `*mut T` like existing APIs (`Cell::as_ptr` / `MaybeUninit::as[_mut]_ptr` / `Vec::as_ptr` / ...) or be more precise and return `NonNull<T>`?
Rollup of 8 pull requests Successful merges: - #140369 (Add data_ptr method to Mutex and RwLock) - #140697 (Split `autodiff` into `autodiff_forward` and `autodiff_reverse`) - #141404 (Improve intrinsic handling in cg_ssa) - #141407 (Refactor the two-phase check for impls and impl items) - #141411 (rustdoc: linking to a local proc macro no longer warns) - #141548 (consider glob imports in cfg suggestion) - #141627 (Drop-build cleanups) - #141670 (Fix ICE in tokenstream with contracts from parser recovery) r? `@ghost` `@rustbot` modify labels: rollup
…manieu Add data_ptr method to Mutex and RwLock Implementation of rust-lang#140368 / rust-lang/libs-team#531. I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course. Unresolved questions: - Return a `LockResult` or not? - Return `*mut T` like existing APIs (`Cell::as_ptr` / `MaybeUninit::as[_mut]_ptr` / `Vec::as_ptr` / ...) or be more precise and return `NonNull<T>`?
Rollup of 8 pull requests Successful merges: - #140369 (Add data_ptr method to Mutex and RwLock) - #140697 (Split `autodiff` into `autodiff_forward` and `autodiff_reverse`) - #141404 (Improve intrinsic handling in cg_ssa) - #141407 (Refactor the two-phase check for impls and impl items) - #141411 (rustdoc: linking to a local proc macro no longer warns) - #141548 (consider glob imports in cfg suggestion) - #141627 (Drop-build cleanups) - #141670 (Fix ICE in tokenstream with contracts from parser recovery) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - #140369 (Add data_ptr method to Mutex and RwLock) - #140697 (Split `autodiff` into `autodiff_forward` and `autodiff_reverse`) - #141404 (Improve intrinsic handling in cg_ssa) - #141411 (rustdoc: linking to a local proc macro no longer warns) - #141548 (consider glob imports in cfg suggestion) - #141627 (Drop-build cleanups) - #141670 (Fix ICE in tokenstream with contracts from parser recovery) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #140369 - jplatte:mutex-rwlock-data-ptr, r=Amanieu Add data_ptr method to Mutex and RwLock Implementation of #140368 / rust-lang/libs-team#531. I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course. Unresolved questions: - Return a `LockResult` or not? - Return `*mut T` like existing APIs (`Cell::as_ptr` / `MaybeUninit::as[_mut]_ptr` / `Vec::as_ptr` / ...) or be more precise and return `NonNull<T>`?
Implementation of #140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
LockResult
or not?*mut T
like existing APIs (Cell::as_ptr
/MaybeUninit::as[_mut]_ptr
/Vec::as_ptr
/ ...) or be more precise and returnNonNull<T>
?