mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-16 04:56:18 +00:00
Refact. Replace all tokio::time::interval() (#7173)
* Refact. Replace all `tokio::time::interval()` Signed-off-by: fufesou <shuanglongchen@yeah.net> * Refact Better min_interval for `ThrottledInterval`. Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -1038,9 +1038,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
||||
|
||||
loop {
|
||||
if let Ok(mut c) = ipc::connect(1000, "").await {
|
||||
const TIMER_OUT: time::Duration = time::Duration::from_secs(1);
|
||||
let mut timer = time::interval(TIMER_OUT);
|
||||
let mut last_timer = time::Instant::now() - TIMER_OUT * 2;
|
||||
let mut timer = crate::rustdesk_interval(time::interval(time::Duration::from_secs(1)));
|
||||
loop {
|
||||
tokio::select! {
|
||||
res = c.next() => {
|
||||
@@ -1108,11 +1106,6 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
||||
allow_err!(c.send(&data).await);
|
||||
}
|
||||
_ = timer.tick() => {
|
||||
if last_timer.elapsed() < TIMER_OUT {
|
||||
continue;
|
||||
}
|
||||
last_timer = time::Instant::now();
|
||||
|
||||
c.send(&ipc::Data::OnlineStatus(None)).await.ok();
|
||||
c.send(&ipc::Data::Options(None)).await.ok();
|
||||
c.send(&ipc::Data::Config(("id".to_owned(), None))).await.ok();
|
||||
|
||||
Reference in New Issue
Block a user