mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
timer: fix Handle::timeout (#1093)
The old implementation didn't work for Timeout<Stream>, since the method took a deadline rather than a timeout.
This commit is contained in:
committed by
Carl Lerche
parent
d4803bc868
commit
b62d224fac
@@ -109,16 +109,13 @@ fn hammer_cancel() {
|
||||
barrier.wait();
|
||||
|
||||
for _ in 0..PER_THREAD {
|
||||
let deadline1 =
|
||||
Instant::now() + Duration::from_millis(rng.gen_range(MIN_DELAY, MAX_DELAY));
|
||||
let timeout1 = Duration::from_millis(rng.gen_range(MIN_DELAY, MAX_DELAY));
|
||||
let timeout2 = Duration::from_millis(rng.gen_range(MIN_DELAY, MAX_DELAY));
|
||||
|
||||
let deadline2 =
|
||||
Instant::now() + Duration::from_millis(rng.gen_range(MIN_DELAY, MAX_DELAY));
|
||||
let deadline = Instant::now() + cmp::min(timeout1, timeout2);
|
||||
|
||||
let deadline = cmp::min(deadline1, deadline2);
|
||||
|
||||
let delay = handle.delay(deadline1);
|
||||
let join = handle.timeout(delay, deadline2);
|
||||
let delay = handle.delay(Instant::now() + timeout1);
|
||||
let join = handle.timeout(delay, timeout2);
|
||||
|
||||
exec.spawn(async move {
|
||||
let _ = join.await;
|
||||
|
||||
Reference in New Issue
Block a user