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

Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) #107736

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,13 +922,13 @@ impl AtomicBool {
///
/// let mut atomic = AtomicBool::new(true);
/// unsafe {
/// my_atomic_op(atomic.as_mut_ptr());
/// my_atomic_op(atomic.as_ptr());
/// }
/// # }
/// ```
#[inline]
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
pub const fn as_mut_ptr(&self) -> *mut bool {
pub const fn as_ptr(&self) -> *mut bool {
self.v.get().cast()
}

Expand Down Expand Up @@ -1814,12 +1814,12 @@ impl<T> AtomicPtr<T> {
///
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
/// unsafe {
/// my_atomic_op(atomic.as_mut_ptr());
/// my_atomic_op(atomic.as_ptr());
/// }
/// ```
#[inline]
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
pub const fn as_mut_ptr(&self) -> *mut *mut T {
pub const fn as_ptr(&self) -> *mut *mut T {
self.p.get()
}
}
Expand Down Expand Up @@ -2719,15 +2719,15 @@ macro_rules! atomic_int {
///
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
/// unsafe {
/// my_atomic_op(atomic.as_mut_ptr());
/// my_atomic_op(atomic.as_ptr());
/// }
/// # }
/// ```
#[inline]
#[unstable(feature = "atomic_mut_ptr",
reason = "recently added",
issue = "66893")]
pub const fn as_mut_ptr(&self) -> *mut $int_type {
pub const fn as_ptr(&self) -> *mut $int_type {
self.v.get()
}
}
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys_common/thread_parking/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Parker {
if state == PARKED {
// Loop to guard against spurious wakeups.
while state == PARKED {
park(self.state.as_mut_ptr().addr());
park(self.state.as_ptr().addr());
state = self.state.load(Acquire);
}

Expand All @@ -76,7 +76,7 @@ impl Parker {

let state = self.state.fetch_sub(1, Acquire).wrapping_sub(1);
if state == PARKED {
park_timeout(dur, self.state.as_mut_ptr().addr());
park_timeout(dur, self.state.as_ptr().addr());
// Swap to ensure that we observe all state changes with acquire
// ordering, even if the state has been changed after the timeout
// occured.
Expand All @@ -99,7 +99,7 @@ impl Parker {
// and terminated before this call is made. This call then returns an
// error or wakes up an unrelated thread. The platform API and
// environment does allow this, however.
unpark(tid, self.state.as_mut_ptr().addr());
unpark(tid, self.state.as_ptr().addr());
}
}
}
Expand Down