aboutsummaryrefslogtreecommitdiff
path: root/src/loom/std/parking_lot.rs
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2020-10-23 09:39:31 -0700
committerJoel Galenson <jgalenson@google.com>2020-10-23 09:52:09 -0700
commitd5495b03381a3ebe0805db353d198b285b535b5c (patch)
tree778b8524d15fca8b73db0253ee0e1919d0848bb6 /src/loom/std/parking_lot.rs
parentba45c5bedf31df8562364c61d3dfb5262f10642e (diff)
downloadtokio-d5495b03381a3ebe0805db353d198b285b535b5c.tar.gz
Update to tokio-0.3.1 and add new features
Test: Build Change-Id: I5b5b9b386a21982a019653d0cf0bd3afc505cfac
Diffstat (limited to 'src/loom/std/parking_lot.rs')
-rw-r--r--src/loom/std/parking_lot.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/loom/std/parking_lot.rs b/src/loom/std/parking_lot.rs
index 25d94af..c03190f 100644
--- a/src/loom/std/parking_lot.rs
+++ b/src/loom/std/parking_lot.rs
@@ -3,7 +3,7 @@
//!
//! This can be extended to additional types/methods as required.
-use std::sync::{LockResult, TryLockError, TryLockResult};
+use std::sync::LockResult;
use std::time::Duration;
// Types that do not need wrapping
@@ -27,16 +27,20 @@ impl<T> Mutex<T> {
}
#[inline]
- pub(crate) fn lock(&self) -> LockResult<MutexGuard<'_, T>> {
- Ok(self.0.lock())
+ #[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
+ #[cfg_attr(docsrs, doc(cfg(all(feature = "parking_lot",))))]
+ pub(crate) const fn const_new(t: T) -> Mutex<T> {
+ Mutex(parking_lot::const_mutex(t))
}
#[inline]
- pub(crate) fn try_lock(&self) -> TryLockResult<MutexGuard<'_, T>> {
- match self.0.try_lock() {
- Some(guard) => Ok(guard),
- None => Err(TryLockError::WouldBlock),
- }
+ pub(crate) fn lock(&self) -> MutexGuard<'_, T> {
+ self.0.lock()
+ }
+
+ #[inline]
+ pub(crate) fn try_lock(&self) -> Option<MutexGuard<'_, T>> {
+ self.0.try_lock()
}
// Note: Additional methods `is_poisoned` and `into_inner`, can be