diff options
Diffstat (limited to 'src/condvar.rs')
-rw-r--r-- | src/condvar.rs | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/condvar.rs b/src/condvar.rs index 534b8af..9eaf300 100644 --- a/src/condvar.rs +++ b/src/condvar.rs @@ -12,10 +12,9 @@ use core::{ fmt, ptr, sync::atomic::{AtomicPtr, Ordering}, }; -use instant::Instant; use lock_api::RawMutex as RawMutex_; use parking_lot_core::{self, ParkResult, RequeueOp, UnparkResult, DEFAULT_PARK_TOKEN}; -use std::time::Duration; +use std::time::{Duration, Instant}; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. @@ -381,12 +380,6 @@ impl Condvar { /// /// Like `wait`, the lock specified will be re-acquired when this function /// returns, regardless of whether the timeout elapsed or not. - /// - /// # Panics - /// - /// Panics if the given `timeout` is so large that it can't be added to the current time. - /// This panic is not possible if the crate is built with the `nightly` feature, then a too - /// large `timeout` becomes equivalent to just calling `wait`. #[inline] pub fn wait_for<T: ?Sized>( &self, @@ -414,11 +407,11 @@ impl fmt::Debug for Condvar { #[cfg(test)] mod tests { use crate::{Condvar, Mutex, MutexGuard}; - use instant::Instant; use std::sync::mpsc::channel; use std::sync::Arc; use std::thread; use std::time::Duration; + use std::time::Instant; #[test] fn smoke() { @@ -557,14 +550,7 @@ mod tests { let _g = m2.lock(); c2.notify_one(); }); - // Non-nightly panics on too large timeouts. Nightly treats it as indefinite wait. - let very_long_timeout = if cfg!(feature = "nightly") { - Duration::from_secs(u64::max_value()) - } else { - Duration::from_millis(u32::max_value() as u64) - }; - - let timeout_res = c.wait_for(&mut g, very_long_timeout); + let timeout_res = c.wait_for(&mut g, Duration::from_secs(u64::max_value())); assert!(!timeout_res.timed_out()); drop(g); |