Rollup merge of #147125 - connortsui20:poison-once-remove, r=tgross35
move `once` module out of `poison` From https://github.com/rust-lang/rust/issues/134645#issuecomment-3324577500, since `Once` will not have a non-poisoning variant, we remove it from the `poison` module. Additionally: 1. Renames `once::ExclusiveState` to `OnceExclusiveState` since it was a bit confusing reading just `ExclusiveState` where it is used. 2. Reorders a few module definitions and re-exports in `library/std/src/sync/mod.rs` for clarity. Also, once this is merged, I think that we can begin the process of stabilizing [`sync_poison_mod`](https://github.com/rust-lang/rust/issues/134646)
This commit is contained in:
commit
79e46694de
7 changed files with 102 additions and 97 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::cell::Cell;
|
||||
use crate::sync as public;
|
||||
use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
|
||||
use crate::sync::poison::once::ExclusiveState;
|
||||
use crate::sync::once::OnceExclusiveState;
|
||||
use crate::sys::futex::{Futex, Primitive, futex_wait, futex_wake_all};
|
||||
|
||||
// On some platforms, the OS is very nice and handles the waiter queue for us.
|
||||
|
|
@ -83,21 +83,21 @@ impl Once {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn state(&mut self) -> ExclusiveState {
|
||||
pub(crate) fn state(&mut self) -> OnceExclusiveState {
|
||||
match *self.state_and_queued.get_mut() {
|
||||
INCOMPLETE => ExclusiveState::Incomplete,
|
||||
POISONED => ExclusiveState::Poisoned,
|
||||
COMPLETE => ExclusiveState::Complete,
|
||||
INCOMPLETE => OnceExclusiveState::Incomplete,
|
||||
POISONED => OnceExclusiveState::Poisoned,
|
||||
COMPLETE => OnceExclusiveState::Complete,
|
||||
_ => unreachable!("invalid Once state"),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn set_state(&mut self, new_state: ExclusiveState) {
|
||||
pub(crate) fn set_state(&mut self, new_state: OnceExclusiveState) {
|
||||
*self.state_and_queued.get_mut() = match new_state {
|
||||
ExclusiveState::Incomplete => INCOMPLETE,
|
||||
ExclusiveState::Poisoned => POISONED,
|
||||
ExclusiveState::Complete => COMPLETE,
|
||||
OnceExclusiveState::Incomplete => INCOMPLETE,
|
||||
OnceExclusiveState::Poisoned => POISONED,
|
||||
OnceExclusiveState::Complete => COMPLETE,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::cell::Cell;
|
||||
use crate::sync as public;
|
||||
use crate::sync::poison::once::ExclusiveState;
|
||||
use crate::sync::once::OnceExclusiveState;
|
||||
|
||||
pub struct Once {
|
||||
state: Cell<State>,
|
||||
|
|
@ -45,21 +45,21 @@ impl Once {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn state(&mut self) -> ExclusiveState {
|
||||
pub(crate) fn state(&mut self) -> OnceExclusiveState {
|
||||
match self.state.get() {
|
||||
State::Incomplete => ExclusiveState::Incomplete,
|
||||
State::Poisoned => ExclusiveState::Poisoned,
|
||||
State::Complete => ExclusiveState::Complete,
|
||||
State::Incomplete => OnceExclusiveState::Incomplete,
|
||||
State::Poisoned => OnceExclusiveState::Poisoned,
|
||||
State::Complete => OnceExclusiveState::Complete,
|
||||
_ => unreachable!("invalid Once state"),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn set_state(&mut self, new_state: ExclusiveState) {
|
||||
pub(crate) fn set_state(&mut self, new_state: OnceExclusiveState) {
|
||||
self.state.set(match new_state {
|
||||
ExclusiveState::Incomplete => State::Incomplete,
|
||||
ExclusiveState::Poisoned => State::Poisoned,
|
||||
ExclusiveState::Complete => State::Complete,
|
||||
OnceExclusiveState::Incomplete => State::Incomplete,
|
||||
OnceExclusiveState::Poisoned => State::Poisoned,
|
||||
OnceExclusiveState::Complete => State::Complete,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
use crate::cell::Cell;
|
||||
use crate::sync::atomic::Ordering::{AcqRel, Acquire, Release};
|
||||
use crate::sync::atomic::{Atomic, AtomicBool, AtomicPtr};
|
||||
use crate::sync::poison::once::ExclusiveState;
|
||||
use crate::sync::once::OnceExclusiveState;
|
||||
use crate::thread::{self, Thread};
|
||||
use crate::{fmt, ptr, sync as public};
|
||||
|
||||
|
|
@ -131,21 +131,21 @@ impl Once {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn state(&mut self) -> ExclusiveState {
|
||||
pub(crate) fn state(&mut self) -> OnceExclusiveState {
|
||||
match self.state_and_queue.get_mut().addr() {
|
||||
INCOMPLETE => ExclusiveState::Incomplete,
|
||||
POISONED => ExclusiveState::Poisoned,
|
||||
COMPLETE => ExclusiveState::Complete,
|
||||
INCOMPLETE => OnceExclusiveState::Incomplete,
|
||||
POISONED => OnceExclusiveState::Poisoned,
|
||||
COMPLETE => OnceExclusiveState::Complete,
|
||||
_ => unreachable!("invalid Once state"),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn set_state(&mut self, new_state: ExclusiveState) {
|
||||
pub(crate) fn set_state(&mut self, new_state: OnceExclusiveState) {
|
||||
*self.state_and_queue.get_mut() = match new_state {
|
||||
ExclusiveState::Incomplete => ptr::without_provenance_mut(INCOMPLETE),
|
||||
ExclusiveState::Poisoned => ptr::without_provenance_mut(POISONED),
|
||||
ExclusiveState::Complete => ptr::without_provenance_mut(COMPLETE),
|
||||
OnceExclusiveState::Incomplete => ptr::without_provenance_mut(INCOMPLETE),
|
||||
OnceExclusiveState::Poisoned => ptr::without_provenance_mut(POISONED),
|
||||
OnceExclusiveState::Complete => ptr::without_provenance_mut(COMPLETE),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue