Skip to content

Commit

Permalink
Add documentation on when Condvar::wait_for can panic
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Dec 4, 2018
1 parent f3f7667 commit 8cafa7d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,17 @@ 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.
#[inline]
pub fn wait_for<T: ?Sized>(
&self,
guard: &mut MutexGuard<T>,
timeout: Duration,
) -> WaitTimeoutResult {
// FIXME: Change to Intstant::now().checked_add(timeout) when stable.
self.wait_until(guard, Instant::now() + timeout)
}
}
Expand Down

0 comments on commit 8cafa7d

Please sign in to comment.