about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/condvar.rs24
-rw-r--r--src/libstd/sync/mod.rs4
-rw-r--r--src/libstd/sync/mutex.rs28
-rw-r--r--src/libstd/sync/rwlock.rs31
4 files changed, 85 insertions, 2 deletions
diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs
index 57932f03796..bf4b119a0b6 100644
--- a/src/libstd/sync/condvar.rs
+++ b/src/libstd/sync/condvar.rs
@@ -72,6 +72,7 @@ impl WaitTimeoutResult {
 /// }
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct Condvar { inner: Box<StaticCondvar> }
 
 /// Statically allocated condition variables.
@@ -91,6 +92,11 @@ pub struct Condvar { inner: Box<StaticCondvar> }
 #[unstable(feature = "static_condvar",
            reason = "may be merged with Condvar in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Condvar::new` in a static should \
+                             suffice")]
 pub struct StaticCondvar {
     inner: sys::Condvar,
     mutex: AtomicUsize,
@@ -100,8 +106,15 @@ pub struct StaticCondvar {
 #[unstable(feature = "static_condvar",
            reason = "may be merged with Condvar in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Condvar::new` in a static should \
+                             suffice")]
+#[allow(deprecated)]
 pub const CONDVAR_INIT: StaticCondvar = StaticCondvar::new();
 
+#[allow(deprecated)]
 impl Condvar {
     /// Creates a new condition variable which is ready to be waited on and
     /// notified.
@@ -228,12 +241,22 @@ impl Default for Condvar {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl Drop for Condvar {
     fn drop(&mut self) {
         unsafe { self.inner.inner.destroy() }
     }
 }
 
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Condvar::new` in a static should \
+                             suffice")]
+#[unstable(feature = "static_condvar",
+           reason = "may be merged with Condvar in the future",
+           issue = "27717")]
+#[allow(deprecated)]
 impl StaticCondvar {
     /// Creates a new condition variable
     #[unstable(feature = "static_condvar",
@@ -392,6 +415,7 @@ impl StaticCondvar {
 }
 
 #[cfg(test)]
+#[allow(deprecated)]
 mod tests {
     use prelude::v1::*;
 
diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs
index 21008ee3989..56eb7340c89 100644
--- a/src/libstd/sync/mod.rs
+++ b/src/libstd/sync/mod.rs
@@ -25,10 +25,13 @@ pub use core::sync::atomic;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::barrier::{Barrier, BarrierWaitResult};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub use self::condvar::{Condvar, StaticCondvar, WaitTimeoutResult, CONDVAR_INIT};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub use self::mutex::MUTEX_INIT;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub use self::mutex::{Mutex, MutexGuard, StaticMutex};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::once::{Once, OnceState, ONCE_INIT};
@@ -37,6 +40,7 @@ pub use sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResul
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT};
 
 pub mod mpsc;
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index 90cc79dad66..15e69628c7a 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -113,6 +113,7 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
 /// *guard += 1;
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct Mutex<T: ?Sized> {
     // Note that this static mutex is in a *box*, not inlined into the struct
     // itself. Once a native mutex has been used once, its address can never
@@ -156,6 +157,11 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
 #[unstable(feature = "static_mutex",
            reason = "may be merged with Mutex in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Mutex::new` in a static should \
+                             suffice")]
 pub struct StaticMutex {
     lock: sys::Mutex,
     poison: poison::Flag,
@@ -168,6 +174,7 @@ pub struct StaticMutex {
 /// `Deref` and `DerefMut` implementations
 #[must_use]
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct MutexGuard<'a, T: ?Sized + 'a> {
     // funny underscores due to how Deref/DerefMut currently work (they
     // disregard field privacy).
@@ -184,8 +191,15 @@ impl<'a, T: ?Sized> !marker::Send for MutexGuard<'a, T> {}
 #[unstable(feature = "static_mutex",
            reason = "may be merged with Mutex in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Mutex::new` in a static should \
+                             suffice")]
+#[allow(deprecated)]
 pub const MUTEX_INIT: StaticMutex = StaticMutex::new();
 
+#[allow(deprecated)]
 impl<T> Mutex<T> {
     /// Creates a new mutex in an unlocked state ready for use.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -197,6 +211,7 @@ impl<T> Mutex<T> {
     }
 }
 
+#[allow(deprecated)]
 impl<T: ?Sized> Mutex<T> {
     /// Acquires a mutex, blocking the current thread until it is able to do so.
     ///
@@ -307,6 +322,7 @@ impl<T: ?Sized> Mutex<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl<T: ?Sized> Drop for Mutex<T> {
     #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
@@ -346,6 +362,12 @@ static DUMMY: Dummy = Dummy(UnsafeCell::new(()));
 #[unstable(feature = "static_mutex",
            reason = "may be merged with Mutex in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `Mutex::new` in a static should \
+                             suffice")]
+#[allow(deprecated)]
 impl StaticMutex {
     /// Creates a new mutex in an unlocked state ready for use.
     pub const fn new() -> StaticMutex {
@@ -391,8 +413,8 @@ impl StaticMutex {
     }
 }
 
+#[allow(deprecated)]
 impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
-
     unsafe fn new(lock: &'mutex StaticMutex, data: &'mutex UnsafeCell<T>)
            -> LockResult<MutexGuard<'mutex, T>> {
         poison::map_result(lock.poison.borrow(), |guard| {
@@ -418,6 +440,7 @@ impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
     #[inline]
     fn drop(&mut self) {
@@ -428,15 +451,18 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
     }
 }
 
+#[allow(deprecated)]
 pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex {
     &guard.__lock.lock
 }
 
+#[allow(deprecated)]
 pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag {
     &guard.__lock.poison
 }
 
 #[cfg(test)]
+#[allow(deprecated)]
 mod tests {
     use prelude::v1::*;
 
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index cfb8ee16cb0..e1e764bd255 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -66,6 +66,7 @@ use sys_common::rwlock as sys;
 /// } // write lock is dropped here
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct RwLock<T: ?Sized> {
     inner: Box<StaticRwLock>,
     data: UnsafeCell<T>,
@@ -104,6 +105,11 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
 #[unstable(feature = "static_rwlock",
            reason = "may be merged with RwLock in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `RwLock::new` in a static should \
+                             suffice")]
 pub struct StaticRwLock {
     lock: sys::RWLock,
     poison: poison::Flag,
@@ -113,12 +119,19 @@ pub struct StaticRwLock {
 #[unstable(feature = "static_rwlock",
            reason = "may be merged with RwLock in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `RwLock::new` in a static should \
+                             suffice")]
+#[allow(deprecated)]
 pub const RW_LOCK_INIT: StaticRwLock = StaticRwLock::new();
 
 /// RAII structure used to release the shared read access of a lock when
 /// dropped.
 #[must_use]
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
     __lock: &'a StaticRwLock,
     __data: &'a T,
@@ -131,6 +144,7 @@ impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
 /// dropped.
 #[must_use]
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
     __lock: &'a StaticRwLock,
     __data: &'a mut T,
@@ -140,6 +154,7 @@ pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T: ?Sized> !marker::Send for RwLockWriteGuard<'a, T> {}
 
+#[allow(deprecated)]
 impl<T> RwLock<T> {
     /// Creates a new instance of an `RwLock<T>` which is unlocked.
     ///
@@ -156,6 +171,7 @@ impl<T> RwLock<T> {
     }
 }
 
+#[allow(deprecated)]
 impl<T: ?Sized> RwLock<T> {
     /// Locks this rwlock with shared read access, blocking the current thread
     /// until it can be acquired.
@@ -325,6 +341,7 @@ impl<T: ?Sized> RwLock<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
 impl<T: ?Sized> Drop for RwLock<T> {
     #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
@@ -360,6 +377,12 @@ static DUMMY: Dummy = Dummy(UnsafeCell::new(()));
 #[unstable(feature = "static_rwlock",
            reason = "may be merged with RwLock in the future",
            issue = "27717")]
+#[rustc_deprecated(since = "1.10.0",
+                   reason = "the lazy-static crate suffices for static sync \
+                             primitives and eventually this type shouldn't \
+                             be necessary as `RwLock::new` in a static should \
+                             suffice")]
+#[allow(deprecated)]
 impl StaticRwLock {
     /// Creates a new rwlock.
     pub const fn new() -> StaticRwLock {
@@ -434,6 +457,7 @@ impl StaticRwLock {
     }
 }
 
+#[allow(deprecated)]
 impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
     unsafe fn new(lock: &'rwlock StaticRwLock, data: &'rwlock UnsafeCell<T>)
            -> LockResult<RwLockReadGuard<'rwlock, T>> {
@@ -482,6 +506,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
     }
 }
 
+#[allow(deprecated)]
 impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> {
     unsafe fn new(lock: &'rwlock StaticRwLock, data: &'rwlock UnsafeCell<T>)
            -> LockResult<RwLockWriteGuard<'rwlock, T>> {
@@ -562,10 +587,12 @@ impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T> {
-    fn deref_mut(&mut self) -> &mut T { self.__data
+    fn deref_mut(&mut self) -> &mut T {
+        self.__data
     }
 }
 
+#[allow(deprecated)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> {
     fn drop(&mut self) {
@@ -573,6 +600,7 @@ impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> {
     }
 }
 
+#[allow(deprecated)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> {
     fn drop(&mut self) {
@@ -582,6 +610,7 @@ impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> {
 }
 
 #[cfg(test)]
+#[allow(deprecated)]
 mod tests {
     #![allow(deprecated)] // rand