Rollup merge of #84387 - CDirkx:poison, r=m-ou-se
Move `sys_common::poison` to `sync::poison` `sys_common` should not contain publicly exported types, only platform-independent abstractions on top of `sys`, which `sys_common::poison` is not. There is thus no reason for the module to not live under `sync`. Part of #84187.
This commit is contained in:
commit
ace3bd4f8b
6 changed files with 15 additions and 14 deletions
|
@ -2,9 +2,8 @@
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::fmt;
|
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::condvar as sys;
|
||||||
use crate::sys_common::poison::{self, LockResult};
|
|
||||||
use crate::time::{Duration, Instant};
|
use crate::time::{Duration, Instant};
|
||||||
|
|
||||||
/// A type indicating whether a timed wait on a condition variable returned
|
/// A type indicating whether a timed wait on a condition variable returned
|
||||||
|
|
|
@ -166,9 +166,9 @@ pub use self::mutex::{Mutex, MutexGuard};
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use self::once::{Once, OnceState, ONCE_INIT};
|
pub use self::once::{Once, OnceState, ONCE_INIT};
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[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")]
|
#[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;
|
pub mod mpsc;
|
||||||
|
|
||||||
|
@ -176,4 +176,5 @@ mod barrier;
|
||||||
mod condvar;
|
mod condvar;
|
||||||
mod mutex;
|
mod mutex;
|
||||||
mod once;
|
mod once;
|
||||||
|
mod poison;
|
||||||
mod rwlock;
|
mod rwlock;
|
||||||
|
|
|
@ -6,8 +6,8 @@ use crate::fmt;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::ops::{Deref, DerefMut};
|
use crate::ops::{Deref, DerefMut};
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
|
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
|
||||||
use crate::sys_common::mutex as sys;
|
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
|
/// A mutual exclusion primitive useful for protecting shared data
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,9 +3,6 @@ use crate::fmt;
|
||||||
use crate::sync::atomic::{AtomicBool, Ordering};
|
use crate::sync::atomic::{AtomicBool, Ordering};
|
||||||
use crate::thread;
|
use crate::thread;
|
||||||
|
|
||||||
#[allow(unused_imports)] // for intra-doc links
|
|
||||||
use crate::sync::{Mutex, RwLock};
|
|
||||||
|
|
||||||
pub struct Flag {
|
pub struct Flag {
|
||||||
failed: AtomicBool,
|
failed: AtomicBool,
|
||||||
}
|
}
|
||||||
|
@ -80,6 +77,8 @@ pub struct Guard {
|
||||||
/// }
|
/// }
|
||||||
/// };
|
/// };
|
||||||
/// ```
|
/// ```
|
||||||
|
/// [`Mutex`]: crate::sync::Mutex
|
||||||
|
/// [`RwLock`]: crate::sync::RwLock
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct PoisonError<T> {
|
pub struct PoisonError<T> {
|
||||||
guard: 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
|
/// 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`].
|
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
|
||||||
///
|
///
|
||||||
/// [`try_lock`]: Mutex::try_lock
|
/// [`try_lock`]: crate::sync::Mutex::try_lock
|
||||||
/// [`try_read`]: RwLock::try_read
|
/// [`try_read`]: crate::sync::RwLock::try_read
|
||||||
/// [`try_write`]: RwLock::try_write
|
/// [`try_write`]: crate::sync::RwLock::try_write
|
||||||
|
/// [`Mutex`]: crate::sync::Mutex
|
||||||
|
/// [`RwLock`]: crate::sync::RwLock
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub enum TryLockError<T> {
|
pub enum TryLockError<T> {
|
||||||
/// The lock could not be acquired because another thread failed while holding
|
/// The lock could not be acquired because another thread failed while holding
|
||||||
|
@ -149,7 +150,8 @@ impl<T> Error for PoisonError<T> {
|
||||||
impl<T> PoisonError<T> {
|
impl<T> PoisonError<T> {
|
||||||
/// Creates a `PoisonError`.
|
/// 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")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn new(guard: T) -> PoisonError<T> {
|
pub fn new(guard: T) -> PoisonError<T> {
|
||||||
PoisonError { guard }
|
PoisonError { guard }
|
|
@ -6,7 +6,7 @@ use crate::fmt;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::ops::{Deref, DerefMut};
|
use crate::ops::{Deref, DerefMut};
|
||||||
use crate::ptr;
|
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;
|
use crate::sys_common::rwlock as sys;
|
||||||
|
|
||||||
/// A reader-writer lock
|
/// A reader-writer lock
|
||||||
|
|
|
@ -59,7 +59,6 @@ pub mod mutex;
|
||||||
// when generating documentation.
|
// when generating documentation.
|
||||||
#[cfg(any(doc, not(windows)))]
|
#[cfg(any(doc, not(windows)))]
|
||||||
pub mod os_str_bytes;
|
pub mod os_str_bytes;
|
||||||
pub mod poison;
|
|
||||||
pub mod process;
|
pub mod process;
|
||||||
pub mod remutex;
|
pub mod remutex;
|
||||||
pub mod rwlock;
|
pub mod rwlock;
|
||||||
|
|
Loading…
Add table
Reference in a new issue