Hi
If there is no request arrived for last 3 seconds, I want idle_timeout
branch to be triggered.
Hence whenever request
branch is fired, I need reset() the delay.
let request = request_rx.fuse();
let response = response_rx.fuse();
let delay = futures_timer::Delay::new(Duration::from_secs(3)); // <-- timer created here
let idle_timeout = delay.fuse();
pin_mut!(request, response, idle_timeout);
loop {
select! {
_ = idle_timeout => {
info!("No request in last 3 seconds");
},
_ = request.next() => {
idle_timeout.get_mut().reset(Duration::from_secs(3)); // <-- reset timer whenever any request arrives
},
_ = response.next() => {
// ...
},
complete => {
return;
}
}
}
The problem is -- futures::future::Fuse<futures_timer::Delay>
does not allow me to access the inner timer. The above code fails with following compliation.
|
251 | ... idle_timeout.get_mut().reset(Duration::from_secs(3));
| ^^^^^ method not found in `&mut futures_util::future::fuse::Fuse<futures_timer::delay::Delay>`
How can I reset the timer in an Fuse
?
futures-timer = 0.4.0
futures-preview = 0.3.0-alpha.19
thank you.