1
Fork 0

revise code to pass the format check

This commit is contained in:
Stefan Lankes 2020-10-06 12:12:15 +02:00
parent 98fcc3fbc7
commit d560b50d87
No known key found for this signature in database
GPG key ID: 28578EBB789EF62B

View file

@ -3,7 +3,7 @@ use crate::collections::VecDeque;
use crate::ffi::c_void; use crate::ffi::c_void;
use crate::ops::{Deref, DerefMut, Drop}; use crate::ops::{Deref, DerefMut, Drop};
use crate::ptr; use crate::ptr;
use crate::sync::atomic::{AtomicUsize, Ordering, spin_loop_hint}; use crate::sync::atomic::{spin_loop_hint, AtomicUsize, Ordering};
use crate::sys::hermit::abi; use crate::sys::hermit::abi;
/// This type provides a lock based on busy waiting to realize mutual exclusion /// This type provides a lock based on busy waiting to realize mutual exclusion
@ -50,10 +50,7 @@ impl<T> Spinlock<T> {
#[inline] #[inline]
pub unsafe fn lock(&self) -> SpinlockGuard<'_, T> { pub unsafe fn lock(&self) -> SpinlockGuard<'_, T> {
self.obtain_lock(); self.obtain_lock();
SpinlockGuard { SpinlockGuard { dequeue: &self.dequeue, data: &mut *self.data.get() }
dequeue: &self.dequeue,
data: &mut *self.data.get(),
}
} }
} }
@ -147,10 +144,7 @@ struct MutexInner {
impl MutexInner { impl MutexInner {
pub const fn new() -> MutexInner { pub const fn new() -> MutexInner {
MutexInner { MutexInner { locked: false, blocked_task: PriorityQueue::new() }
locked: false,
blocked_task: PriorityQueue::new(),
}
} }
} }
@ -163,9 +157,7 @@ unsafe impl Sync for Mutex {}
impl Mutex { impl Mutex {
pub const fn new() -> Mutex { pub const fn new() -> Mutex {
Mutex { Mutex { inner: Spinlock::new(MutexInner::new()) }
inner: Spinlock::new(MutexInner::new()),
}
} }
#[inline] #[inline]
@ -211,8 +203,7 @@ impl Mutex {
} }
#[inline] #[inline]
pub unsafe fn destroy(&self) { pub unsafe fn destroy(&self) {}
}
} }
pub struct ReentrantMutex { pub struct ReentrantMutex {