Skip to content

Commit 0f64588

Browse files
committed
Add test for wait_timeout with no lock held
1 parent 7c76869 commit 0f64588

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/condvar.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use async_std::sync::{Condvar, Mutex};
66
use async_std::task::{self, JoinHandle};
77

88
#[test]
9-
fn wait_timeout() {
9+
fn wait_timeout_with_lock() {
1010
task::block_on(async {
1111
let pair = Arc::new((Mutex::new(false), Condvar::new()));
1212
let pair2 = pair.clone();
@@ -26,6 +26,17 @@ fn wait_timeout() {
2626
})
2727
}
2828

29+
#[test]
30+
fn wait_timeout_without_lock() {
31+
task::block_on(async {
32+
let m = Mutex::new(false);
33+
let c = Condvar::new();
34+
35+
let (_, wait_result) = c.wait_timeout(m.lock().await, Duration::from_millis(10)).await;
36+
assert!(wait_result.timed_out());
37+
})
38+
}
39+
2940
#[test]
3041
fn wait_timeout_until_timed_out() {
3142
task::block_on(async {

0 commit comments

Comments
 (0)