diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2015-04-04 00:46:54 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2015-04-08 19:42:16 +0300 |
| commit | 45aa6c8d1bc2f7863c92da6643de4642bb2d83bf (patch) | |
| tree | 53f8648a696dc49072ceef53c36974f6fc599515 /src/libstd/sync/mod.rs | |
| parent | 80def6c2447d23a624e611417f24cf0ab2a5a676 (diff) | |
| download | rust-45aa6c8d1bc2f7863c92da6643de4642bb2d83bf.tar.gz rust-45aa6c8d1bc2f7863c92da6643de4642bb2d83bf.zip | |
Implement reentrant mutexes and make stdio use them
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides write_fmt to lock the stdio handle for the whole duration of the call.
Diffstat (limited to 'src/libstd/sync/mod.rs')
| -rw-r--r-- | src/libstd/sync/mod.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index a5259a00390..91e9714fbef 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -20,15 +20,15 @@ pub use alloc::arc::{Arc, Weak}; pub use core::atomic; -pub use self::mutex::{Mutex, MutexGuard, StaticMutex}; -pub use self::mutex::MUTEX_INIT; -pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT}; -pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard}; +pub use self::barrier::{Barrier, BarrierWaitResult}; pub use self::condvar::{Condvar, StaticCondvar, CONDVAR_INIT}; +pub use self::mutex::MUTEX_INIT; +pub use self::mutex::{Mutex, MutexGuard, StaticMutex}; pub use self::once::{Once, ONCE_INIT}; +pub use sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; +pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard}; +pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT}; pub use self::semaphore::{Semaphore, SemaphoreGuard}; -pub use self::barrier::{Barrier, BarrierWaitResult}; -pub use self::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; pub use self::future::Future; @@ -39,6 +39,5 @@ mod condvar; mod future; mod mutex; mod once; -mod poison; mod rwlock; mod semaphore; |
