mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-23 02:27:39 +03:00
45aa6c8d1b
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.
44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
//! Useful synchronization primitives
|
|
//!
|
|
//! This module contains useful safe and unsafe synchronization primitives.
|
|
//! Most of the primitives in this module do not provide any sort of locking
|
|
//! and/or blocking at all, but rather provide the necessary tools to build
|
|
//! other types of concurrent primitives.
|
|
|
|
#![stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
pub use alloc::arc::{Arc, Weak};
|
|
pub use core::atomic;
|
|
|
|
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::future::Future;
|
|
|
|
pub mod mpsc;
|
|
|
|
mod barrier;
|
|
mod condvar;
|
|
mod future;
|
|
mod mutex;
|
|
mod once;
|
|
mod rwlock;
|
|
mod semaphore;
|