提交 acc3ab4e 编写于 作者: M Mara Bos

Make all {Mutex, Condvar, RwLock}::new #[inline].

上级 e70c60d3
......@@ -123,7 +123,8 @@ impl Condvar {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
pub fn new() -> Condvar {
#[inline]
pub const fn new() -> Condvar {
Condvar { inner: sys::Condvar::new() }
}
......
......@@ -214,7 +214,8 @@ impl<T> Mutex<T> {
/// let mutex = Mutex::new(0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(t: T) -> Mutex<T> {
#[inline]
pub const fn new(t: T) -> Mutex<T> {
Mutex {
inner: sys::MovableMutex::new(),
poison: poison::Flag::new(),
......
......@@ -19,6 +19,7 @@ pub struct Flag {
// all cases.
impl Flag {
#[inline]
pub const fn new() -> Flag {
Flag { failed: AtomicBool::new(false) }
}
......
......@@ -146,7 +146,8 @@ impl<T> RwLock<T> {
/// let lock = RwLock::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(t: T) -> RwLock<T> {
#[inline]
pub const fn new(t: T) -> RwLock<T> {
RwLock {
inner: sys::MovableRwLock::new(),
poison: poison::Flag::new(),
......
......@@ -26,6 +26,7 @@ fn new_mtx() -> Result<abi::ID, ItronError> {
}
impl Mutex {
#[inline]
pub const fn new() -> Mutex {
Mutex { mtx: SpinIdOnceCell::new() }
}
......
......@@ -23,6 +23,7 @@ fn new_rwl() -> Result<abi::ID, ItronError> {
}
impl RwLock {
#[inline]
pub const fn new() -> RwLock {
RwLock { rwl: SpinIdOnceCell::new() }
}
......
......@@ -6,6 +6,7 @@ pub struct Condvar {}
pub type MovableCondvar = Condvar;
impl Condvar {
#[inline]
pub const fn new() -> Condvar {
Condvar {}
}
......
......@@ -11,6 +11,7 @@ unsafe impl Send for Mutex {}
unsafe impl Sync for Mutex {} // no threads on this platform
impl Mutex {
#[inline]
pub const fn new() -> Mutex {
Mutex { locked: Cell::new(false) }
}
......
......@@ -11,6 +11,7 @@ unsafe impl Send for RwLock {}
unsafe impl Sync for RwLock {} // no threads on this platform
impl RwLock {
#[inline]
pub const fn new() -> RwLock {
RwLock { mode: Cell::new(0) }
}
......
......@@ -14,6 +14,7 @@ unsafe impl Send for Condvar {}
unsafe impl Sync for Condvar {}
impl Condvar {
#[inline]
pub const fn new() -> Condvar {
Condvar { inner: UnsafeCell::new(c::CONDITION_VARIABLE_INIT) }
}
......
......@@ -33,6 +33,7 @@ pub unsafe fn raw(m: &Mutex) -> c::PSRWLOCK {
}
impl Mutex {
#[inline]
pub const fn new() -> Mutex {
Mutex { srwlock: UnsafeCell::new(c::SRWLOCK_INIT) }
}
......
......@@ -11,6 +11,7 @@ unsafe impl Send for RwLock {}
unsafe impl Sync for RwLock {}
impl RwLock {
#[inline]
pub const fn new() -> RwLock {
RwLock { inner: UnsafeCell::new(c::SRWLOCK_INIT) }
}
......
......@@ -14,7 +14,8 @@ pub struct Condvar {
impl Condvar {
/// Creates a new condition variable for use.
pub fn new() -> Self {
#[inline]
pub const fn new() -> Self {
Self { inner: imp::MovableCondvar::new(), check: CondvarCheck::new() }
}
......
......@@ -15,6 +15,7 @@ unsafe impl Sync for StaticMutex {}
impl StaticMutex {
/// Creates a new mutex for use.
#[inline]
pub const fn new() -> Self {
Self(imp::Mutex::new())
}
......@@ -60,6 +61,7 @@ unsafe impl Sync for MovableMutex {}
impl MovableMutex {
/// Creates a new mutex.
#[inline]
pub fn new() -> Self {
Self(imp::MovableMutex::new())
}
......
......@@ -10,6 +10,7 @@
impl StaticRwLock {
/// Creates a new rwlock for use.
#[inline]
pub const fn new() -> Self {
Self(imp::RwLock::new())
}
......@@ -73,6 +74,7 @@ fn drop(&mut self) {
impl MovableRwLock {
/// Creates a new reader-writer lock for use.
#[inline]
pub fn new() -> Self {
Self(imp::MovableRwLock::new())
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册