diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-12-22 00:49:42 +0100 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-12-26 17:26:33 +0100 |
| commit | f436f9ca2963e33cc41802370bb9c551c833970e (patch) | |
| tree | c79b09c0cb3024b389027fd2a501a44a0a1f9bb9 /src/libstd/sync | |
| parent | 686ce664da31f87b8d1c7377313f160d8fdcebe9 (diff) | |
| download | rust-f436f9ca2963e33cc41802370bb9c551c833970e.tar.gz rust-f436f9ca2963e33cc41802370bb9c551c833970e.zip | |
Make Send and Sync traits unsafe
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 9 | ||||
| -rw-r--r-- | src/libstd/sync/once.rs | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 2849813c510..d2dafac281a 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -11,7 +11,7 @@ use prelude::*; use cell::{UnsafeCell, RacyCell}; -use kinds::marker; +use kinds::{marker, Sync}; use sync::{poison, AsMutexGuard}; use sys_common::mutex as sys; @@ -73,9 +73,9 @@ pub struct Mutex<T> { data: RacyCell<T>, } -impl<T:Send> Send for Mutex<T> { } +unsafe impl<T:Send> Send for Mutex<T> { } -impl<T:Send> Sync for Mutex<T> { } +unsafe impl<T:Send> Sync for Mutex<T> { } /// The static mutex type is provided to allow for static allocation of mutexes. /// @@ -98,12 +98,13 @@ impl<T:Send> Sync for Mutex<T> { } /// } /// // lock is unlocked here. /// ``` -#[deriving(Sync)] pub struct StaticMutex { lock: sys::Mutex, poison: RacyCell<poison::Flag>, } +unsafe impl Sync for StaticMutex {} + /// An RAII implementation of a "scoped lock" of a mutex. When this structure is /// dropped (falls out of scope), the lock will be unlocked. /// diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 4b940b0420a..4d9fbb59908 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -14,6 +14,7 @@ //! example use case would be for initializing an FFI library. use int; +use kinds::Sync; use mem::drop; use ops::FnOnce; use sync::atomic; @@ -35,13 +36,14 @@ use sync::{StaticMutex, MUTEX_INIT}; /// // run initialization here /// }); /// ``` -#[deriving(Sync)] pub struct Once { mutex: StaticMutex, cnt: atomic::AtomicInt, lock_cnt: atomic::AtomicInt, } +unsafe impl Sync for Once {} + /// Initialization value for static `Once` values. pub const ONCE_INIT: Once = Once { mutex: MUTEX_INIT, |
