Skip to content

Commit

Permalink
Merge pull request #237 from Enselic/remove-unneeded-phantomdata
Browse files Browse the repository at this point in the history
Remove `PhantomData<*mut Waiter>` so we don't need to manually `impl Send`
  • Loading branch information
matklad committed Jun 4, 2023
2 parents de29dd9 + 3fcb189 commit 51a9724
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/imp_std.rs
Expand Up @@ -5,7 +5,6 @@

use std::{
cell::{Cell, UnsafeCell},
marker::PhantomData,
panic::{RefUnwindSafe, UnwindSafe},
sync::atomic::{AtomicBool, AtomicPtr, Ordering},
thread::{self, Thread},
Expand All @@ -22,7 +21,6 @@ pub(crate) struct OnceCell<T> {
// State is encoded in two low bits. Only `INCOMPLETE` and `RUNNING` states
// allow waiters.
queue: AtomicPtr<Waiter>,
_marker: PhantomData<*mut Waiter>,
value: UnsafeCell<Option<T>>,
}

Expand All @@ -32,7 +30,6 @@ pub(crate) struct OnceCell<T> {
// then destroyed by A. That is, destructor observes
// a sent value.
unsafe impl<T: Sync + Send> Sync for OnceCell<T> {}
unsafe impl<T: Send> Send for OnceCell<T> {}

impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceCell<T> {}
impl<T: UnwindSafe> UnwindSafe for OnceCell<T> {}
Expand All @@ -41,15 +38,13 @@ impl<T> OnceCell<T> {
pub(crate) const fn new() -> OnceCell<T> {
OnceCell {
queue: AtomicPtr::new(INCOMPLETE_PTR),
_marker: PhantomData,
value: UnsafeCell::new(None),
}
}

pub(crate) const fn with_value(value: T) -> OnceCell<T> {
OnceCell {
queue: AtomicPtr::new(COMPLETE_PTR),
_marker: PhantomData,
value: UnsafeCell::new(Some(value)),
}
}
Expand Down

0 comments on commit 51a9724

Please sign in to comment.