mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-27 14:24:08 +00:00
std: Stabilize the sync_poison feature
These accessor/constructor methods for a `PoisonError` are quite standard for a wrapper type and enable manipulation of the underlying type.
This commit is contained in:
parent
68b628b165
commit
c032d6fd39
@ -238,7 +238,7 @@ impl<T: ?Sized> Mutex<T> {
|
|||||||
/// time. You should not trust a `false` value for program correctness
|
/// time. You should not trust a `false` value for program correctness
|
||||||
/// without additional synchronization.
|
/// without additional synchronization.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "sync_poison")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn is_poisoned(&self) -> bool {
|
pub fn is_poisoned(&self) -> bool {
|
||||||
self.inner.poison.get()
|
self.inner.poison.get()
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ impl<T: ?Sized> RwLock<T> {
|
|||||||
/// time. You should not trust a `false` value for program correctness
|
/// time. You should not trust a `false` value for program correctness
|
||||||
/// without additional synchronization.
|
/// without additional synchronization.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "sync_poison")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn is_poisoned(&self) -> bool {
|
pub fn is_poisoned(&self) -> bool {
|
||||||
self.inner.poison.get()
|
self.inner.poison.get()
|
||||||
}
|
}
|
||||||
|
@ -120,24 +120,24 @@ impl<T: Send + Reflect> Error for PoisonError<T> {
|
|||||||
|
|
||||||
impl<T> PoisonError<T> {
|
impl<T> PoisonError<T> {
|
||||||
/// Creates a `PoisonError`.
|
/// Creates a `PoisonError`.
|
||||||
#[unstable(feature = "sync_poison")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn new(guard: T) -> PoisonError<T> {
|
pub fn new(guard: T) -> PoisonError<T> {
|
||||||
PoisonError { guard: guard }
|
PoisonError { guard: guard }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes this error indicating that a lock is poisoned, returning the
|
/// Consumes this error indicating that a lock is poisoned, returning the
|
||||||
/// underlying guard to allow access regardless.
|
/// underlying guard to allow access regardless.
|
||||||
#[unstable(feature = "sync_poison")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn into_inner(self) -> T { self.guard }
|
pub fn into_inner(self) -> T { self.guard }
|
||||||
|
|
||||||
/// Reaches into this error indicating that a lock is poisoned, returning a
|
/// Reaches into this error indicating that a lock is poisoned, returning a
|
||||||
/// reference to the underlying guard to allow access regardless.
|
/// reference to the underlying guard to allow access regardless.
|
||||||
#[unstable(feature = "sync_poison")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn get_ref(&self) -> &T { &self.guard }
|
pub fn get_ref(&self) -> &T { &self.guard }
|
||||||
|
|
||||||
/// Reaches into this error indicating that a lock is poisoned, returning a
|
/// Reaches into this error indicating that a lock is poisoned, returning a
|
||||||
/// mutable reference to the underlying guard to allow access regardless.
|
/// mutable reference to the underlying guard to allow access regardless.
|
||||||
#[unstable(feature = "sync_poi")]
|
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||||
pub fn get_mut(&mut self) -> &mut T { &mut self.guard }
|
pub fn get_mut(&mut self) -> &mut T { &mut self.guard }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user