Explorar el Código

fix: high CPU usage

mrxiaozhuox hace 3 años
padre
commit
25e3ee848c
Se han modificado 1 ficheros con 1 adiciones y 0 borrados
  1. 1 0
      src/server/mod.rs

+ 1 - 0
src/server/mod.rs

@@ -118,6 +118,7 @@ async fn ws_handler(
 ) -> impl IntoResponse {
     ws.on_upgrade(|mut socket| async move {
         loop {
+            tokio::time::sleep(tokio::time::Duration::from_millis(1200)).await;
             if state.lock().unwrap().update {
                 socket
                     .send(Message::Text(String::from("reload")))