Move sys_common::poison to sync::poison

This commit is contained in:
Christiaan Dirkx 2021-04-21 10:05:11 +02:00
parent 71965ab4d0
commit 9cabbd0afc
6 changed files with 15 additions and 14 deletions

View File

@ -2,9 +2,8 @@
mod tests;
use crate::fmt;
use crate::sync::{mutex, MutexGuard, PoisonError};
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
use crate::sys_common::condvar as sys;
use crate::sys_common::poison::{self, LockResult};
use crate::time::{Duration, Instant};
/// A type indicating whether a timed wait on a condition variable returned

View File

@ -166,9 +166,9 @@
#[allow(deprecated)]
pub use self::once::{Once, OnceState, ONCE_INIT};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys_common::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub mod mpsc;
@ -176,4 +176,5 @@
mod condvar;
mod mutex;
mod once;
mod poison;
mod rwlock;

View File

@ -6,8 +6,8 @@
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::mutex as sys;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
/// A mutual exclusion primitive useful for protecting shared data
///

View File

@ -3,9 +3,6 @@
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::thread;
#[allow(unused_imports)] // for intra-doc links
use crate::sync::{Mutex, RwLock};
pub struct Flag {
failed: AtomicBool,
}
@ -80,6 +77,8 @@ pub struct Guard {
/// }
/// };
/// ```
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub struct PoisonError<T> {
guard: T,
@ -89,9 +88,11 @@ pub struct PoisonError<T> {
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
///
/// [`try_lock`]: Mutex::try_lock
/// [`try_read`]: RwLock::try_read
/// [`try_write`]: RwLock::try_write
/// [`try_lock`]: crate::sync::Mutex::try_lock
/// [`try_read`]: crate::sync::RwLock::try_read
/// [`try_write`]: crate::sync::RwLock::try_write
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding
@ -149,7 +150,8 @@ fn description(&self) -> &str {
impl<T> PoisonError<T> {
/// Creates a `PoisonError`.
///
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
/// This is generally created by methods like [`Mutex::lock`](crate::sync::Mutex::lock)
/// or [`RwLock::read`](crate::sync::RwLock::read).
#[stable(feature = "sync_poison", since = "1.2.0")]
pub fn new(guard: T) -> PoisonError<T> {
PoisonError { guard }

View File

@ -6,7 +6,7 @@
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::rwlock as sys;
/// A reader-writer lock

View File

@ -59,7 +59,6 @@ macro_rules! rtunwrap {
// when generating documentation.
#[cfg(any(doc, not(windows)))]
pub mod os_str_bytes;
pub mod poison;
pub mod process;
pub mod remutex;
pub mod rwlock;