Skip to content

Commit

Permalink
Inline AtomicUsize::const_new to just AtomicUsize::new
Browse files Browse the repository at this point in the history
  • Loading branch information
mental32 committed Sep 7, 2020
1 parent 39b8a30 commit a1fa12a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions tokio/src/loom/std/atomic_usize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ unsafe impl Send for AtomicUsize {}
unsafe impl Sync for AtomicUsize {}

impl AtomicUsize {
pub(crate) fn new(val: usize) -> AtomicUsize {
let inner = UnsafeCell::new(std::sync::atomic::AtomicUsize::new(val));
AtomicUsize { inner }
}

#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
pub(crate) const fn const_new(val: usize) -> AtomicUsize {
pub(crate) const fn new(val: usize) -> AtomicUsize {
let inner = UnsafeCell::new(std::sync::atomic::AtomicUsize::new(val));
AtomicUsize { inner }
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/batch_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Semaphore {
pub(crate) const fn const_new(permits: usize) -> Self {
// FIXME: assertions and by extension panics are still being worked on: https://github.com/rust-lang/rust/issues/74925
Self {
permits: AtomicUsize::const_new(permits << Self::PERMIT_SHIFT),
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT),
waiters: Mutex::const_new(Waitlist {
queue: LinkedList::new(),
closed: false,
Expand Down

0 comments on commit a1fa12a

Please sign in to comment.