summaryrefslogtreecommitdiffstats
path: root/library/std/src/sys/unsupported/once.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/unsupported/once.rs')
-rw-r--r--library/std/src/sys/unsupported/once.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/std/src/sys/unsupported/once.rs b/library/std/src/sys/unsupported/once.rs
index b4bb4975f..11fde1888 100644
--- a/library/std/src/sys/unsupported/once.rs
+++ b/library/std/src/sys/unsupported/once.rs
@@ -1,5 +1,6 @@
use crate::cell::Cell;
use crate::sync as public;
+use crate::sync::once::ExclusiveState;
pub struct Once {
state: Cell<State>,
@@ -44,6 +45,16 @@ impl Once {
self.state.get() == State::Complete
}
+ #[inline]
+ pub(crate) fn state(&mut self) -> ExclusiveState {
+ match self.state.get() {
+ State::Incomplete => ExclusiveState::Incomplete,
+ State::Poisoned => ExclusiveState::Poisoned,
+ State::Complete => ExclusiveState::Complete,
+ _ => unreachable!("invalid Once state"),
+ }
+ }
+
#[cold]
#[track_caller]
pub fn call(&self, ignore_poisoning: bool, f: &mut impl FnMut(&public::OnceState)) {