Tracking Issue for const_atomic
Open
Nobody has claimed this yet.
C-tracking-issue
S-tracking-unimplemented
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(const_atomic)]
This is a tracking issue for atomic operations in const.
Public API
// core::sync::atomic
impl AtomicBool {
pub const fn get_mut(&mut self) -> &mut bool;
pub const fn from_mut(v: &mut bool) -> &mut Self;
pub const fn get_mut_slice(this: &mut [Self]) -> &mut [bool];
pub const fn from_mut_slice(v: &mut [bool]) -> &mut [Self];
pub const fn load(&self, order: Ordering) -> bool;
pub const fn store(&self, val: bool, order: Ordering);
pub const fn swap(&self, val: bool, order: Ordering) -> bool;
pub const fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool;
pub const fn compare_exchange(
&self,
current: bool,
new: bool,
success: Ordering,
failure: Ordering,
) -> Result<bool, bool>;
pub const fn compare_exchange_weak(
&self,
current: bool,
new: bool,
success: Ordering,
failure: Ordering,
) -> Result<bool, bool>;
pub const fn fetch_and(&self, val: bool, order: Ordering) -> bool;
pub const fn fetch_nand(&self, val: bool, order: Ordering) -> bool;
pub const fn fetch_or(&self, val: bool, order: Ordering) -> bool;
pub const fn fetch_xor(&self, val: bool, order: Ordering) -> bool;
pub const fn fetch_not(&self, order: Ordering) -> bool;
}
impl AtomicPtr<T> {
pub const fn get_mut(&mut self) -> &mut *mut T;
pub const fn from_mut(v: &mut *mut T) -> &mut Self;
pub const fn get_mut_slice(this: &mut [Self]) -> &mut [*mut T];
pub const fn from_mut_slice(v: &mut [*mut T]) -> &mut [Self];
pub const fn load(&self, order: Ordering) -> *mut T;
pub const fn store(&self, ptr: *mut T, order: Ordering);
pub const fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T;
}
impl Atomic$Int {
pub const fn get_mut(&mut self) -> &mut $int_type;
pub const fn from_mut(v: &mut $int_type) -> &mut Self;
pub const fn get_mut_slice(this: &mut [Self]) -> &mut [$int_type];
pub const fn from_mut_slice(v: &mut [$int_type]) -> &mut [Self];
pub const fn load(&self, order: Ordering) -> $int_type;
pub const fn store(&self, val: $int_type, order: Ordering);
pub const fn swap(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn compare_and_swap(&self,
current: $int_type,
new: $int_type,
order: Ordering) -> $int_type;
pub const fn compare_exchange(&self,
current: $int_type,
new: $int_type,
success: Ordering,
failure: Ordering) -> Result<$int_type, $int_type>;
pub const fn compare_exchange_weak(&self,
current: $int_type,
new: $int_type,
success: Ordering,
failure: Ordering) -> Result<$int_type, $int_type>;
pub const fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type;
pub const fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type;
}
pub const fn fence(order: Ordering);
pub const fn compiler_fence(order: Ordering);
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Implementation: https://github.com/rust-lang/rust/pull/160079
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
-
compare_and_swapare deprecated. Should we still make themconst fn? Seems odd to make everythingconst fnexcept for these.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked implementation PR #160079 and the public API listed in this issue. Done means the implementation, final comment period, and stabilization PR are complete, with the unresolved question about const compare_and_swap addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100